API Docs
/
No Results Found
Self Client

Self Client AI Tools

Open in ChatGPT

Open in ChatGPT to ask questions about this page

Open in Claude

Open in Claude to ask questions about this page

Copy as Markdown

Copy this page as markdown to use with AI assistants

View as Markdown

Open this page as markdown in a new tab

Suppose you want your app to fetch data from your own Arattai account, or set up app-to-app communication in the backend without any user interaction. In that case, you can use the Self Client option. In this situation, you will be the resource owner, and no end-user authorization is required. The client will request access permission on its own behalf and not on behalf of any end-user.

Follow the steps to set up Self Client:

Create a self-client in the API console.

  1. Go to the Arattai API console.
  2. Click GET STARTED.
  3. Hover over the Self Client option and click CREATE NOW.
  4. Click on CREATE, then click OK. A Client ID and Client Secret will be generated and displayed under the Client Secret tab. You can copy them. Get access token

There are two ways in which you can get an access token for your self client:

  • Authorization code grant flow
  • Client credentials grant flow
Arattai Oauth Self Client types

In the authorization code grant flow, you will need to generate an authorization code from the API console and then exchange it for an access token and a refresh token. When the access token expires, you can use the refresh token to get a new access token. See API reference

In the client credentials grant flow, you must provide your client credentials to obtain an access token. Note that a refresh token will not be issued. Consequently, you will need to repeat the same request to get a new access token whenever it is required. For more details, please refer to the API documentation.

Self Client - Authorization code flow

Step 1: Generate an authorization code

  1. Navigate to the created Self Client in the API console.
  2. In the Generate Code tab:
    • Enter the scopes that your app requires access to, separated by commas. You can refer to Arattai's available scopes for guidance.
    • Select an expiry time for the authorization code. By default, it is 3 minutes.
    • Enter a description for the required scopes.
  3. Click CREATE. An authorization code will be generated and displayed.
  4. Copy or download the authorization code.

Step 2: Get access token and refresh token

Exchange the authorization code for an access token and a refresh token.

Note: The API call to exchange the authorization code for an access token and refresh token is the same across all OAuth client types that use the authorization code flow. Only the authorization code generation step differs between client types.

Query parameters

Parameter Description
client_id required
A unique ID displayed under Self Client > Client Secret.
client_secret required
A unique confidential secret displayed under Self Client > Client Secret.
grant_type required
Should be passed with the value authorization_code.
code required
The authorization code generated in the previous step.

Response parameters

Parameter Description
access_token An authorized key that can be used by your application to access the required resource (mentioned in the scope). Validity: 1 hour.
refresh_token A special token that can be used by your application to refresh the access token once it is expired. This token won't expire.
token_type Indicates the type of access token that is generated. The token type that is used in Arattai's OAuth implementation is Bearer.
expires_in Indicates the time (in seconds) in which the access token will expire.

Endpoint

Click to copy
POST https://accounts.arattai.in/oauth/v2/token

Request Example

Click to copy
https://accounts.arattai.in/oauth/v2/token?client_id=1000.XMDEG1KBDO9SE2IFTMDFSRPYYJ5L0U&client_secret=1632308b34e2cf614fed922c5d6c4193c7778a5f13&grant_type=authorization_code&code=1000.406a3b53bad3f6824d4fb43108604cd7.a74aef3010243f0fae78111e2a673847

Response Example

{ "access_token": "1000.875cf8ea310ae70c6fb26e25a5a48df0.be3bc88ac53c61", "refresh_token": "1000.ce79a5110c4097744b17aecbb95dcfb.db312474fc80e", "token_type": "Bearer", "expires_in": 3600 }

Step 3: Use the access token to make API calls

Make request calls to the service you want to access through the api_domain you get from the response of the access token request. Using an access token, you can access the resource for an hour, after which it will expire. To get a new access token, use the refresh token (see Step 4).


Step 4: Refresh the access token when it expires

When an access token expires, get a new access token using the refresh token.

Refresh token can be obtained only when access_type is set to offline while creating the access token.

Query parameters

Parameter Description
client_id required
A unique ID displayed under Self Client > Client Secret.
client_secret required
A unique confidential secret displayed under Self Client > Client Secret.
grant_type required
Should be passed with the value refresh_token.
refresh_token required
The refresh token you've obtained in Step 2.

Response parameters

Parameter Description
access_token An authorized key that can be used by your application to access the required resource (mentioned in the scope). Validity: 1 hour.
token_type Indicates the type of access token that is generated. The token type that is used in Arattai's OAuth implementation is Bearer.
expires_in Indicates the time (in seconds) in which the access token will expire.


Endpoint

Click to copy
POST https://accounts.arattai.in/oauth/v2/token

Request Example

Click to copy
https://accounts.arattai.in/oauth/v2/token?client_id=1000.XMDEG1KBDO9SE2IFTMDFSRPYYJ5L0U&client_secret=1632308b34e2cf614fed922c5d6c4193c7778a5f13&grant_type=refresh_token&code=1000.406a3b53bad3f6824d4fb43108604cd7.a74aef3010243f0fae78111e2a673847

Response Example

{ "access_token": "1000.875cf8ea310ae70c6fb26e25a5a48df0.be3bc88ac53c61", "refresh_token": "1000.ce79a5110c4097744b17aecbb95dcfb.db312474fc80e", "token_type": "Bearer", "expires_in": 3600 }

Self Client - Client credentials flow

Step 1: Use the client credentials to get access token

Use your client credentials to directly obtain an access token from the Arattai authorization server.

Query parameters

Parameter Description
client_id required
A unique ID displayed under Self Client > Client Secret.
client_secret required
A unique confidential secret displayed under Self Client > Client Secret.
grant_type required
Should be passed with the value client_credentials.
scope required
The scope(s) for the resources you want to access using the access token. Multiple scopes can be separated by commas.

Response parameters

Parameter Description
access_token An authorized key that can be used by your application to access the required resource (mentioned in the scope). Validity: 1 hour.
token_type Indicates the type of access token that is generated. The token type that is used in Arattai's OAuth implementation is Bearer.
expires_in Indicates the time (in seconds) in which the access token will expire.


Endpoint

Click to copy
POST https://accounts.arattai.in/oauth/v2/token

Request Example

Click to copy
https://accounts.arattai.in/oauth/v2/token?client_id=1000.XMDEG1KBDO9SE2IFTMDFSRPYYJ5L0U&client_secret=1632308b34e2cf614fed922c5d6c4193c7778a5f13&grant_type=authorization_code&code=1000.406a3b53bad3f6824d4fb43108604cd7.a74aef3010243f0fae78111e2a673847

Response Example

{ "access_token": "1000.875cf8ea310ae70c6fb26e25a5a48df0.be3bc88ac53c61", "token_type": "Bearer", "expires_in": 3600 }

Step 2: Use the access token to make API calls

Make request calls to the service you want to access through the api_domain you get from the response of the access token request. Using an access token, you can access the resource for an hour, after which it will expire. To get a new access token, use the refresh token (see Step 4).