# Flows
Kullanıcı doğrulama ve destek akış tanımlarını içeririr.
**Tüm akışlar token servisi üzerinden çalışmaktadır.**
Eğer bir Grant için Worklfow tanımlanmışsa o grant direkt çağrılabilir. Eğer workflow tanımı yapılmamışsa ilgili grant bir akışın parça adımı olarak düşünülmeli ve mutlaka **flow_grant** tokenı ile çağrılmalıdır.
> * Flowlar **Zeebe** üzerinde çalışan iş akışlarıdır.
> * **/authorize** sayfası ve süreci benzer şekilde token servisi üzerinden geliştirilir.
> * Akış Client ile haberleşmesini **SignalR** ile yapar.
>
| Grants | Factor | WF | Grant | Schema |
| -------------------- | ------ | --------------------- | ------------------------------------------------------------------ | ------ |
| AuthorizationCode | 2FA | wf-authorization-code | authorization_code | |
| UsernamePassword | 1FA | wf-login | password | |
| ResetPassword | | wf-reset-password | http://account.burgan.com.tr/oauth/grant-type/username-phone | |
| sms-otp | 1FA | | http://account.burgan.com.tr/oauth/grant-type/otp | |
| call-otp | 1FA | | http://account.burgan.com.tr/oauth/grant-type/call | |
| device-id | 1FA | | http://account.burgan.com.tr/oauth/grant-type/device-id | |
| push-approve | 1FA | | http://account.burgan.com.tr/oauth/grant-type/push-approve | |
| set-password | | | http://account.burgan.com.tr/oauth/grant-type/set-password | |
| security-pin | 1FA | | http://account.burgan.com.tr/oauth/grant-type/security-pin | |
| set-security-pin | | | http://account.burgan.com.tr/oauth/grant-type/set-security-pin | |
| push-approve | 1FA | | http://account.burgan.com.tr/oauth/grant-type/push-approve | |
| card-pin | 1FA | | http://account.burgan.com.tr/oauth/grant-type/card-pin | |
| set-security-picture | | | http://account.burgan.com.tr/oauth/grant-type/set-security-picture | |
## Reset Password Grant için Schema Örneği
Şemalar [JSON Schema](https://json-schema.org) olarak tanımlanır.
Şemaya uygun veriler json formatında token methoduna **data** değişkeni ile **POST** edilitir.
```json
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "http://example.com/example.json",
"type": "object",
"default": {},
"title": "Root Schema",
"required": [
"username",
"gsm-phone"
],
"properties": {
"username": {
"type": "integer",
"default": 0,
"title": "The username Schema",
"examples": [
3856968651
]
},
"gsm-phone": {
"type": "integer",
"default": 0,
"title": "The gsm-phone Schema",
"examples": [
5302896073
]
}
},
"examples": [{
"username": 3856968651,
"gsm-phone": 5302896073
}]
}
```
## Authorization Code ile Token Alımı
### Request
```haskell
POST account.burgan.com.tr/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code &
code=SplxlOBeZQQYbYS6WxSbIA &
client_id=burgan_web_ib &
scope=38552069008 &
code_verifier=karatas2323 &
redirect_uri=ebank.burgan.com.tr/token
```
### Response
```haskell
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
{
"access_token":"MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3....",
"token_type":"Bearer",
"expires_in":3600,
"scope": 38552069008,
"refresh_token":"IwOGYzYTlmM2YxOTQ5MGE3YmNmMDFkNTVk....",
"identity_token":"asASsadasASDdsadsaSADsaGE3YmNmMDFkNTVk....",
}
```
:::danger
Workflow uzerinden yonetilecegi icin, grant yerine **transitionlar** ile gelistirecegiz.
:::
## UsernamePassword ile Token başlatma
Bu MFA sürecine bir örnek olarak olup şifre değiştirme, ilk şifre alma, müşteri aktivasyonu gibi ek süreçler içinde uygulanabilir akış sunmaktadır.
**1FA**
### Request
```haskell
POST account.burgan.com.tr/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type=password &
client_id=burgan_web_ib &
username=38552069008
password=1234luggage
scope=38552069008 &
```
### Response
```haskell
HTTP/1.1 403 OK
Content-Type: application/json
Cache-Control: no-store
{
"error": "more_grants_required",
"error_description": "Multifactor authentication required",
"flow_token": "Fe26IwOGYzYTlmM2YxOTQ5MGE3YmNmMDFkNTVkHa....",
"available-grants": [
{
"grant-type": "http://account.burgan.com.tr/oauth/grant-type/device-id"
},
{
"grant-type": "http://account.burgan.com.tr/oauth/grant-type/push-approve"
}
]
}
```
**2FA**
### Request
```haskell
POST account.burgan.com.tr/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
grant_type=http://account.burgan.com.tr/oauth/grant-type/device-id &
client_id=burgan_web_ib &
code=1234532345435 &
token=Fe26IwOGYzYTlmM2YxOTQ5MGE3YmNmMDFkNTVkHa... &
scope=38552069008
```
### Response
```haskell
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
{
"access_token":"MTQ0NjJkZmQ5OTM2NDE1ZTZjNGZmZjI3....",
"token_type":"Bearer",
"expires_in":3600,
"scope": 38552069008,
"refresh_token":"IwOGYzYTlmM2YxOTQ5MGE3YmNmMDFkNTVk....",
"identity_token":"asASsadasASDdsadsaSADsaGE3YmNmMDFkNTVk....",
}
```