To obtain an authentication token, meticulously follow these steps:#
1.
Gather Essential Information:Authorization Code: Retrieve the code from the successful authorization request.
Client Identifier (client_id): Obtain this string from the RETM Dev Portal.
Client Secret (client_secret): Securely retrieve this string from the RETM Dev Portal.
2.
Construct the POST Request:Staging: https://stg.retm.sa/api/oAuth/token
Production: https://{business_id}.retm.sa/api/oAuth/token
Replace {business_id}
with the actual business ID.
{
"code": "YOUR_AUTHORIZATION_CODE",
"grant_type": "authorization_code",
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}
3.
Carefully Handle the Response:Upon successful authentication, the response will contain the authentication token, token type, expiration time, and potentially a refresh token.
Inspect the response for any potential errors and handle them accordingly.
Key Considerations:#
Secure Credential Storage: Never store your client ID or client secret in plain text. Utilize secure storage mechanisms to safeguard them.
Environment-Specific URLs: Employ the appropriate URL based on the API environment you're interacting with (staging or production).
Business ID in Production: For production requests, remember to incorporate the business ID within the URL.
By adhering to these guidelines, you'll effectively acquire authentication tokens and securely interact with RETM APIs.