/
Ajio New Access Token Generate Flow

Ajio New Access Token Generate Flow

**NOTE: Ajio Access Token will expire in 30 minutes as this timeline is shared by Ajio Team

Step 1. Fetch all the active connections from eshopbox_wms_production.channels table using IntegrationType = '16' (Ajio Dropship)

SQL Query:

SELECT DISTINCT connectionId AS connectionIds FROM channels WHERE integrationType ='16'AND channels.status='0'

Step 2. Now once the connections list has been fetched, use the below query to fetch accessToken, refreshToken, ExpiryAt etc details from integration_engine_prod.ie_app_install_connection table:

SQL Query:

SELECT ie_appinstall_connection.id AS connectionId, ie_appinstall_connection.inputFields AS inputFields, ie_appinstall_connection.accessTokenExpiryAt AS accessTokenExpiryAt FROM ie_appinstall_connection WHERE ie_appinstall_connection.id IN ( 11,99 ) AND ie_appinstall_connection.isActive='active'

Response: Possible result would be like following:

connectionId

inputFields

accessTokenExpiryAt

connectionId

inputFields

accessTokenExpiryAt

11

{"username":"abc@itc.com","password":"abc123"}

2022-08-17 16:25:08

99

{"username":"brand@itc.com","password":"pqr123"}

2022-08-17 16:25:08

Step 3. Now, once we have this information, for each connection check if the accessTokenExpiryAt < currentTime + 10 mins, if yes then Prepare the Request Body to Regenerate the Access Token as shown below:

 

Note:

  • Here expiry-> accessTokenExpiryAt is a unique time when the particular connection ID is being created the first time.

  • cron run time-> the current time at which the query has been created.

  • So, out of 10 connections, let say for 6 connections if (accessTokenExpiryAt- cron run time) <= 30 min (+ve value), then the 6 connections will be pushed to task queue. remaining connections will be ignored.

Transformation:

Ajio Token Generate API Keys

Eshopbox Keys

Ajio Token Generate API Keys

Eshopbox Keys

username

inputFields.username

password

inputFields.password

Step 4. Now once the transformation is done, call the Ajio Token Generate API:

POST API:

https://api-seller.services.ajio.com/authToken

Request Body:

{ "username": "abc123@itc.com", "password": "abc124" }

Response:

{ "success": true, "statusCode": 0, "result": { "accessToken": "string", "refreshToken": "string" } }

Step 5. Check the status of the response if true, then retrieve the accessToken and refreshToken then save them into integration_engine_prod.ie_appinstall_connection table along with accessTokenExpiryAt when the token was generated.

SQL QUERY:

UPDATE ie_appinstall_connection SET accessToken="",refreshToken="", accessTokenExpiryAt="2022-08-19T22:22:22"

 

Related content