Environment Setup
Go2Joy API URL
Environment
URL
Rate Limiting
Partner provides IP for whitelist
APIs has Authorization by provide the signature via Authorization
APIs provides 2 languages (Vietnamese, English) via Localization
APIs needs default parameters: Client-ID, Timestamp
Type
Parameters
Description
Header
Authorization*
Signature of partners
Header
Localization
The language for title (en, vi). Default is en
Header
Timestamp*
The current timestamp when calling api. Expires in 5 minutes.
Header
Client-ID*
A secret key is distributed to partner.
How to configure authentication
1. Prerequisites
You already have client id and client secret key.
You already have a public app or web application.
2. Signature algorithm
Go2Joy verifies the identity of each API request, and the server will also verify whether the call parameters are valid. Therefore, each HTTP request must contain the signature information. The requests with invalid signature will be rejected.
This part explains how to generate an HMAC-SHA256 signature for an HTTP request. The request used to demonstrate signing is a POST to https://partnership.go2joy.vn/api/v1/hotel/updateHotelInfo. The raw request looks like this sample:
Copy
3. Creating the signature base string
The three values collected must be joined to make a single string, from which the signature will be generated. This is called the signature base string.
Sort all request parameters according to the parameter name in ASCII table.
Example:
Before sort:
Copy
After sort:
Copy
The signature base string is formed by concatenating Timestamp|URL|Body (Body must be encoded).
Copy
There should be no space in the base string.
Note:
When using HMAC to sign the HTTP GET Request, you do not have a body. So your the signature base string is formed by concatenating Timestamp|URL (URL included query params. Query params must be sorted according to the parameter name in ASCII table too)
4. Client secret key
A secret key is distributed to partner when the registration is completed. Please keep the key as secret as your account password. Never disclose the key to anyone else.
5. Calculating the signature
Finally, the signature is calculated by passing the signature base string and client secret key to the HMAC-SHA256 hashing algorithm. The details of the algorithm are explained in depth here.
The output of the HMAC signing function is a binary string. This needs to be hex encoded to produce the signature string.
Copy
Example:
Copy
Sample code for PHP:
Copy
Last updated