Skip to main content

Access Token B2B2C

Specification

The Following tabel is spesification for this API :

API NameAccess Token B2B2C
FunctionThis API is used to finalized account binding process by exchanging the authCode into accessToken that can be used as user authorization
Service Code74
MethodPOST
URL/snap/v1.0/access-token/b2b2c
Acceptapplication/json
Content Typeapplication/json
Related ServiceAccount Binding & Unbinding

Request

The following part will be describe about parameter of request in this API:

Request Parameter

The following table is a list of request parameter in this API:

The following table is Header of Request Parameters :

NoNameTypeLengthRequiredConditionRemarks
1Content-TypeStringVariable, 127 maxMandatory-Content type, value always application/json
2X-TIMESTAMPStringFixed, 25 maxMandatory-Transaction date time, in format YYYY-MM-DDTHH:mm:ss+07:00. Time must be in GMT+7 (Jakarta time)
3X-CLIENT-KEYStringVariable, 36 maxMandatory-Client ID given by the API provider
4X-SIGNATUREStringVariableMandatory-Signature need to be generated with Asymmetric Signature method

Body

The following table is a body of request parameter:

NoNameTypeLengthRequiredConditionRemarks
1grantTypeStringFixed, 18 maxMandatory-Apply token request key type, can be AUTHORIZATION_CODE or REFRESH_TOKEN
2authCodeString256Conditional-The authorization code received after the User provides the consent. Mandatory if grantType = AUTHORIZATION_CODE
3refreshTokenString256Conditional-This token is used for refresh session if existing token has been expired. Mandatory if grantType = REFRESH_TOKEN

Request Sample

The following script is a request sample of this API:

POST /snap/v1.0/access-token/b2b2c 
X-TIMESTAMP: 2024-08-01T08:03:34+07:00
X-CLIENT-KEY: 35d1a1127182a65e4fe0256242a40a6d
X-SIGNATURE: caUdPl+w99Ky9UbODG0rT0dmXmoqN1Um54FzPa/Tf0c9Uefo6vP1hYDbBz2zim6zz2+fnGOuT837YWLBWVZf1OvkD5wmfX5YInr56O+KwbF8v1xKthehs94Fx5mxhnDhH1cNaWXpdFqT4IuhtGdCigY3Cya1Z23jBJK2pV7z0HZqB8HWS9zWjdvIZq3BmGFOAGZLsFiq8voFNuprVLYMafWNWjra3mxMasZzfBqPS6fyAJmQuaSMOarRSRZYy46FtFAIn0Kivq7TI9EAK0ZXb9ShTClhBgwzvNw+vKU5SnO8XfupwgtxNTAU74CeT1TDK61KLv2ukOPuKTarMOdeAA==
Content-Type: application/json

{
"grantType":"AUTHORIZATION_CODE",
"authCode": "74d4b6b2c08bf42595fc8ff81c35704bd444867bd064ae417911b03f9efb4bde"
}

Response

The following part will be describe about parameter of response in this API:

Response Parameter

The following table is a list of response parameter in this API:

Body

The following table is a body of response parameter:

NoNameTypeLengthRequiredConditionRemarks
1responseCodeStringFixed, 7 maxMandatory-Refer to response code list
2responseMessageStringVariable, 150 maxMandatory-Refer to response code list
3accessTokenStringVariable, 2048 maxMandatory-A string representing an authorization issued to the client that used to access protected resources.
4tokenTypeStringFixed, 6 maxMandatory-

The access token type provides the client with the information required to successfully utilize the access token to make a protected resource request (along with type-specific attributes)

. Token Type Value:
  • “Bearer”: includes the access token string in the request
  • “Mac”: issuing a Message Authentication Code (MAC) key together with the access token that is used to sign certain components of the HTTP requests

Reference: OAuth2.0 RFC 6749 & 6750

5accessTokenExpiryTimeStringFixed, 25 maxMandatory-

Time when the accessToken will be expired
Access token valid time will be 15 days
format ISO8601

6refreshTokenStringVariable, 512 maxMandatory-A random string that can be used by specific client to get a refreshed accessToken to prolong the access to the User's resources
7refreshTokenExpiryTimeStringFixed, 25 maxMandatory-

Time when the refreshToken will be expired. Refresh Token should be less than access token validity and will be manage by the PJP’s application to generate a new access_token
format ISO8601

Response Sample

The following script is a response sample of this API:

{
"responseCode": "2007400",
"responseMessage": "Successful",
"accessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJQYXlkaWEiLCJpYXQiOjE3MjI0OTg1OTcsImV4cCI6MTczODI2NjU5NywianRpIjoiNzRkNGI2YjJjMDhiZjQyNTk1ZmM4ZmY4MWMzNTcwNGJkNDQ0ODY3YmQwNjRhZTQxNzkxMWIwM2Y5ZWZiNGJkZSIsImNsaWVudF9pZCI6ImRVVT0iLCJzY29wZSI6IlBVQkxJQ19JRCIsInN0YXRlIjoiNTY0YjJjZTQtYjg1Zi00OWJlLTk1M2EtNzRhMmFiNjE4ZGE5In0.31SVm5lcOxDzdnyIpi3bbDAiL8kk_PAZOF2LusdEDRQ",
"tokenType": "Bearer",
"accessTokenExpiryTime": "2025-01-31T02:49:57+07:00",
"refreshToken": "74d4b6b2c08bf42595fc8ff81c35704bd444867bd064ae417911b03f9efb4bde",
"refreshTokenExpiryTime": "2025-01-31T02:49:57+07:00"
}

Response Code and Message

The following table is the list response code and message of Access Token B2B2C API:

NoResponse CodeResponse MessageRemarks
12007400SuccessfulSuccess to be processed
24007401Invalid Field FormatInvalid format for certain field
34007402Invalid Mandatory FieldMissing or invalid format on mandatory field
44017400Unauthorized. [reason]General unauthorized error
55007402Backend system failure500 internal server error