> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Token Acquisition Methods

> There are two types of methods for acquiring tokens. These methods are activated by selecting one of the "Manage From This Policy" or "Manage From ACL" options through the created JWT/OAuth2 Policy.

There are two types of methods for acquiring tokens. These methods are activated by selecting one of the "Manage From This Policy" or "Manage From ACL" options through the created JWT/OAuth2 Policy. Token acquisition operations will be explained in detail for both methods.

## 1. Token Acquisition with "Manage From This Policy" Option

<Info>
  The ways to obtain **client\_id** and **client\_secret** values according to the management level of the Authentication policy are as follows:

  * **If Authentication Policy is Added to API Proxy:** client\_id and client\_secret values are obtained from the "Show Proxy Key" section in the Overview section of the API Proxy.
  * **If Authentication Policy is Added to Proxy Group:** client\_id and client\_secret values are obtained from the "Show Proxy Key" section in the Overview section of the API Proxy Group.
  * **If Authentication Policy is Added to Policy Group:** client\_id and client\_secret values are obtained from the "Show Proxy Key" section in the Definition section of the relevant Policy Group.
</Info>

### 1.1 Token Acquisition with JWT

If the "Manage From This Policy" option is selected in the created JWT Policy, tokens are acquired using this method.

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/auth/jwt`.

<Info>
  If the **Allow URL Parameters** option is selected, information can be sent using GET method and URL parameters. (See the table below for parameters to be sent)
</Info>

* HTTP Method should be POST.
* "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below.

| Key Name       | Value to Enter if "client\_credentials" is Selected When Defining Policy | Value to Enter if "password" is Selected When Defining Policy          |
| -------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
| grant\_type    | client\_credentials                                                      | password                                                               |
| client\_id     | Public Key value obtained from API Key field                             | Public Key value obtained from API Key field                           |
| client\_secret | Secret Key value obtained from API Key field                             | "-" (dash)                                                             |
| username       | This field is not added                                                  | Username of one of the records in the authentication pool you selected |
| password       | This field is not added                                                  | Password of one of the records in the authentication pool you selected |

#### Token Refresh

If the **Token Should Be Immortal** option is closed and the **Token Refresh Should Be** option is opened, *tokens* that will become invalid after a certain period can be refreshed within the period specified in the **Refreshed Token Validity Period** field.

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/auth/jwt`.

<Info>
  If the **Allow URL Parameters** option is selected, information can be sent using GET method through URL parameters. (See the table below for parameters to be sent).
</Info>

* HTTP Method should be POST.
* "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below.

| Key Name       | Key Value                                                          |
| -------------- | ------------------------------------------------------------------ |
| grant\_type    | refresh\_token                                                     |
| client\_id     | Public Key value obtained from API Key field                       |
| client\_secret | "-" (dash)                                                         |
| refresh\_token | Value in the "refresh\_token" key in the previously acquired token |

#### If grant\_type is client\_credentials

Add a JWT Authentication policy with default values. While doing this, copy your API Key information to use.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/jwt-client-credentials-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=370d25266ece76df9ecc42c320ed832b" alt="JWT Client Credentials Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/jwt-client-credentials-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/jwt-client-credentials-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=c6c6ad17e0854974f8a9ee3ce7844ef0" alt="Sending Request with JWT Token" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/jwt-client-credentials-usage.png" />

#### If grant\_type is password

Add a JWT Authentication policy with Grant Type value Password. While doing this, copy your API Key information to use.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/jwt-password-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=05d3c58c5acf0c3c1166767f470dd49a" alt="JWT Password Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/jwt-password-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/jwt-password-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=1b8b32fd25d6ec35880825d8df117800" alt="Sending Request with JWT Password Token" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/jwt-password-usage.png" />

#### If grant\_type is refresh\_token

Add a JWT Authentication policy with refresh option enabled. While doing this, copy your API Key information to use.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/jwt-refresh-token-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=d5a36da04d096b4c5969915aad0f92c7" alt="JWT Refresh Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/jwt-refresh-token-request.png" />

To refresh the token, take the value in the "refresh\_token" field in the response from the first request and give it as a value to the refresh\_token key in the message you prepared as below.

The value in the "access\_token" field in the response to come will be your refreshed token value.

**The image containing the example request sent to refresh the token through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/jwt-refresh-token-refresh.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=c1ba3ac42016c2c15df6d6f5388e18a7" alt="JWT Refresh Token Refresh" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/jwt-refresh-token-refresh.png" />

### 1.2 Token Acquisition with OAuth2

If the "Manage From This Policy" option is selected in the created OAuth2 Policy, tokens are acquired using this method.

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/auth/token`.

<Info>
  If the **Allow URL Parameters** option is selected, information can be sent using GET method and URL parameters. (See the table below for parameters to be sent)
</Info>

* HTTP method should be POST.
* "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below.

| Key Name       | Value to Enter if "client\_credentials" is Selected When Defining Policy | Value to Enter if "password" is Selected When Defining Policy          |
| -------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
| grant\_type    | client\_credentials                                                      | password                                                               |
| client\_id     | Public Key value obtained from API Key field                             | Public Key value obtained from API Key field                           |
| client\_secret | Secret Key value obtained from API Key field                             | Secret Key value obtained from API Key field                           |
| username       | This field is not added                                                  | Username of one of the records in the authentication pool you selected |
| password       | This field is not added                                                  | Password of one of the records in the authentication pool you selected |

#### Token Refresh

If the **Token Should Be Immortal** option is closed and the **Token Refresh Should Be** option is opened, *tokens* that will become invalid after a certain period can be refreshed within the period specified in the **Refreshed Token Validity Period** field.

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/auth/token`.

<Info>
  If the **Allow URL Parameters** option is selected, information can be sent using GET method through URL parameters. (See the table below for parameters to be sent).
</Info>

* HTTP method should be POST.
* "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below

| Key Name       | Key Value                                                          |
| -------------- | ------------------------------------------------------------------ |
| grant\_type    | refresh\_token                                                     |
| client\_id     | Public Key value obtained from API Key field                       |
| client\_secret | Secret Key value obtained from API Key field                       |
| refresh\_token | Value in the "refresh\_token" key in the previously acquired token |

#### If grant\_type is client\_credentials

Add an OAuth2 Authentication policy with default values. While doing this, copy your API Key information to use.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-client-credentials-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=5b6836f41e182199c8b43d68ed8b29b9" alt="OAuth2 Client Credentials Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-client-credentials-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-client-credentials-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=a39453f4aa50dede3efd6b3d6652271e" alt="Sending Request with OAuth2 Token" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-client-credentials-usage.png" />

#### If grant\_type is password

Add an OAuth2 Authentication policy with Grant Type value Password. While doing this, copy your API Key information to use.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-password-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=10d0274a6b2b125afcae099794318f80" alt="OAuth2 Password Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-password-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-password-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=d09725a4bd4d3c4dee1674acd48967db" alt="Sending Request with OAuth2 Password Token" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-password-usage.png" />

#### GrantType: Refresh Token

Add an OAuth2 Authentication policy with refresh option enabled. While doing this, copy your API Key information to use.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-refresh-token-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=adea99398b9bb03a5733c873debabea9" alt="OAuth2 Refresh Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-refresh-token-request.png" />

To refresh the token, take the value in the "refresh\_token" field in the response from the first request and give it as a value to the refresh\_token key in the message you prepared as below.

The value in the "access\_token" field in the response to come will be your refreshed token value.

**The image containing the example request sent to refresh the token through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-refresh-token-refresh.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=ac7f6fce9907565196a8fa90aeff2ebd" alt="OAuth2 Refresh Token Refresh" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/oauth2-refresh-token-refresh.png" />

### 1.3 Token Acquisition with Scope

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/auth/jwt`.
* HTTP Method should be POST. "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below

| Key Name       | Value to Enter if "client\_credentials" is Selected When Defining Policy | Value to Enter if "password" is Selected When Defining Policy          |
| -------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
| grant\_type    | client\_credentials                                                      | password                                                               |
| client\_id     | Public Key value obtained from API Key field                             | Public Key value obtained from API Key field                           |
| client\_secret | Secret Key value obtained from API Key field                             | "-" (dash)                                                             |
| username       | This field is not added                                                  | Username of one of the records in the authentication pool you selected |
| password       | This field is not added                                                  | Password of one of the records in the authentication pool you selected |
| scope          | Role name defined for the user                                           | Role name defined for the user                                         |

#### Defining Role for User

To define a role for the user, a new role should be added from the roles section as below and that Proxy should be added to the user from the API Proxy ACL section.

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/scope-role-definition.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=ea8c5f63177680a57246a38306f32641" alt="Role Definition with Scope" width="800" style={{maxWidth: '800px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/scope-role-definition.png" />

#### If grant\_type is client\_credentials

Add a JWT Authentication policy with default values. While doing this, copy your API Key information to use.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/scope-client-credentials-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=34389dd30d8c98f2a63176f2e8b243f4" alt="Client Credentials Token Request with Scope" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/scope-client-credentials-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/scope-client-credentials-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=aff64cbb5581bf707fd7b136de20996a" alt="Token Usage with Scope" width="800" style={{maxWidth: '800px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/scope-client-credentials-usage.png" />

#### If grant\_type is password

Add a JWT Authentication policy with Grant Type value Password. While doing this, copy your API Key information to use.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/scope-password-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=5ba6108d47f0ec32160104564b169d36" alt="Password Token Request with Scope" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/scope-password-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/scope-password-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=97efbb615532aec849eff916d260a61f" alt="Password Token Usage with Scope" width="800" style={{maxWidth: '800px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/scope-password-usage.png" />

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/scope-password-usage-2.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=add8b8331b1226eee031a7fe8ca55b18" alt="Password Token Usage with Scope 2" width="800" style={{maxWidth: '800px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/scope-password-usage-2.png" />

## 2. Token Acquisition with "Manage From ACL" Option

### 2.1 Token Acquisition with JWT

If the "Manage From ACL" option is selected in the created JWT Policy, tokens are acquired using this method.

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/credential/jwt`.

<Info>
  If the **Allow URL Parameters** option is selected, information can be sent using GET method and URL parameters. (See the table below for parameters to be sent)
</Info>

* HTTP Method should be POST.
* "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below.

| Key Name       | Value to Enter if "client\_credentials" is Selected When Defining Policy | Value to Enter if "password" is Selected When Defining Policy          |
| -------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
| grant\_type    | client\_credentials                                                      | password                                                               |
| client\_id     | Client Id value belonging to Credentials                                 | Client Id value belonging to Credentials                               |
| client\_secret | Client Secret value belonging to Credentials                             | Client Secret value belonging to Credentials                           |
| username       | This field is not added                                                  | Username of one of the records in the authentication pool you selected |
| password       | This field is not added                                                  | Password of one of the records in the authentication pool you selected |

#### Token Refresh

If the **Token Should Be Immortal** option is closed and the **Token Refresh Should Be** option is opened, *tokens* that will become invalid after a certain period can be refreshed within the period specified in the **Refreshed Token Validity Period** field.

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/credential/jwt`.

<Info>
  If the **Allow URL Parameters** option is selected, information can be sent using GET method through URL parameters. (See the table below for parameters to be sent).
</Info>

* HTTP Method should be POST.
* "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below.

| Key name       | Key Value                                                          |
| -------------- | ------------------------------------------------------------------ |
| grant\_type    | refresh\_token                                                     |
| client\_id     | Client Id value belonging to Credentials                           |
| client\_secret | Client Secret value belonging to Credentials                       |
| refresh\_token | Value in the "refresh\_token" key in the previously acquired token |

#### If grant\_type is client\_credentials

Add a JWT Authentication policy with Manage From ACL option. Go to Token Settings panel from Credential screen and save default values.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-client-credentials-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=2da43e794eaa8040032f0cda7799cf1e" alt="ACL JWT Client Credentials Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-client-credentials-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-client-credentials-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=05be52e6e852aa88891b37aec1431262" alt="Sending Request with ACL JWT Token" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-client-credentials-usage.png" />

#### If grant\_type is password

Add a JWT Authentication policy with Manage From ACL option. Go to Token Settings panel from Credential screen, select Grant Type value as Password and save.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-password-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=f096c7c8c212032cd86cb7cc48b58d83" alt="ACL JWT Password Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-password-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-password-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=9a4ea0022d76adadfe22774986b4c2e2" alt="Sending Request with ACL JWT Password Token" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-password-usage.png" />

#### If grant\_type is refresh\_token

Add a JWT Authentication policy with Manage From ACL option. Go to Token Settings panel from Credential screen, enable Token Refresh option and save.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-refresh-token-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=28f05488bb0a915d21f5b40246414a5b" alt="ACL JWT Refresh Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-refresh-token-request.png" />

To refresh the token, take the value in the "refresh\_token" field in the response from the first request and give it as a value to the refresh\_token key in the message you prepared as below.

The value in the "access\_token" field in the response to come will be your refreshed token value.

**The image containing the example request sent to refresh the token through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-refresh-token-refresh.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=f6d675b89c0240ee5e524adcc43646cf" alt="ACL JWT Refresh Token Refresh" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-jwt-refresh-token-refresh.png" />

### 2.2 Token Acquisition with OAuth2

If the "Manage From ACL" option is selected in the created OAuth2 Policy, tokens are acquired using this method.

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/credential/token`.

<Info>
  If the **Allow URL Parameters** option is selected, information can be sent using GET method and URL parameters. (See the table below for parameters to be sent)
</Info>

* HTTP method should be POST.
* "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below.

| Key Name       | Value to Enter if "client\_credentials" is Selected When Defining Policy | Value to Enter if "password" is Selected When Defining Policy          |
| -------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------- |
| grant\_type    | client\_credentials                                                      | password                                                               |
| client\_id     | Client Id value belonging to Credentials                                 | Client Id value belonging to Credentials                               |
| client\_secret | Client Secret value belonging to Credentials                             | Client Secret value belonging to Credentials                           |
| username       | This field is not added                                                  | Username of one of the records in the authentication pool you selected |
| password       | This field is not added                                                  | Password of one of the records in the authentication pool you selected |

#### Token Refresh

If the **Token Should Be Immortal** option is closed and the **Token Refresh Should Be** option is opened, *tokens* that will become invalid after a certain period can be refreshed within the period specified in the **Refreshed Token Validity Period** field.

Prepare a new HTTP request using Apinizer Test Console or another application of your choice.

* The address should be entered similar to the following according to your own Apinizer access address: `https://apinizerErisimAdresiniz/credential/token`.

<Info>
  If the **Allow URL Parameters** option is selected, information can be sent using GET method through URL parameters. (See the table below for parameters to be sent).
</Info>

* HTTP method should be POST.
* "x-www-form-urlencoded" value should be selected in the Body field. If Apinizer Test Console is not used, a header should be added with "Content-Type" name and "application/x-www-form-urlencoded" value.
* The values to be entered in the Body field are as shown in the table below

| Key Name       | Key Value                                                          |
| -------------- | ------------------------------------------------------------------ |
| grant\_type    | refresh\_token                                                     |
| client\_id     | Client Id value belonging to Credentials                           |
| client\_secret | Client Secret value belonging to Credentials                       |
| refresh\_token | Value in the "refresh\_token" key in the previously acquired token |

#### If grant\_type is client\_credentials

Add an OAuth2 Authentication policy with Manage From ACL option. Go to Token Settings panel from Credential screen and save default values.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-client-credentials-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=dee527af33f596701b915f3e602b5b25" alt="ACL OAuth2 Client Credentials Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-client-credentials-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-client-credentials-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=fe03a2ccf847933f2c86596b1bc43930" alt="Sending Request with ACL OAuth2 Token" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-client-credentials-usage.png" />

#### If grant\_type is password

Add an OAuth2 Authentication policy with Manage From ACL option. Go to Token Settings panel from Credential screen, select Grant Type value as Password and save.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-password-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=e755919548217ec44dec99e0928b9e8e" alt="ACL OAuth2 Password Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-password-request.png" />

The value in the "access\_token" field in the response message, when given as a value to the "Authorization" key in all requests to be sent to this API Proxy, provides secure access to the relevant API.

**The image containing the operation of sending a request with token information through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-password-usage.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=9e331cae648058624e52446ad4fa7d41" alt="Sending Request with ACL OAuth2 Password Token" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-password-usage.png" />

#### If grant\_type is refresh\_token

Add an OAuth2 Authentication policy with Manage From ACL option. Go to Token Settings panel from Credential screen, enable Token Refresh option and save.

Send your token acquisition request with a message like the example below.

**The image containing the settings for sending a request to Token Service through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-refresh-token-request.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=99ed97c6e3ed729ba2e0bac382b5fe30" alt="ACL OAuth2 Refresh Token Request" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-refresh-token-request.png" />

To refresh the token, take the value in the "refresh\_token" field in the response from the first request and give it as a value to the refresh\_token key in the message you prepared as below.

The value in the "access\_token" field in the response to come will be your refreshed token value.

**The image containing the example request sent to refresh the token through Apinizer Test Console is shown below:**

<img src="https://mintcdn.com/apinizer/uqgSOM5xX2YCmzwS/images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-refresh-token-refresh.png?fit=max&auto=format&n=uqgSOM5xX2YCmzwS&q=85&s=5e033667b8f34c0b783a39f2a1b399d9" alt="ACL OAuth2 Refresh Token Refresh" width="600" style={{maxWidth: '600px', width: '100%', height: 'auto'}} data-path="images/develop/politikalar/token-service/token-alma-yontemleri/acl-oauth2-refresh-token-refresh.png" />
