Skip to content

Authentication

If your application needs to access a Cloud user's business data — such as product or order information — via the ZhenHub Open Platform, it must first obtain an access token through user authorization.

To do this, you need to guide the seller through the "Login with Cloud account and authorize application" process. This process follows the OAuth 2.0 international standard protocol for secure user authentication and authorization.

To initiate the OAuth 2.0 authorization flow, construct the authorization URL using the following format:

Test Environment Authorization URL:

Production Environment Authorization URL:

Note: Replace the values in curly brackets ({}) with the actual parameters from your application. For example, {client_id} should be replaced with your registered application's client ID.

Parameter information:

ParameterRequired?Example ValueDescription
client_idYeszhenhub_h***********WhwThe Client Key of your application, assigned by ZhenHub Open Platform.
redirect_uriYeshttps://yourapp.com/callbackThe redirect URI provided during app creation. This must exactly match the one registered in your application settings.
response_typeYescodeThe type of response expected. For authorization code flow, the value must be code.
stateYesYour secure random string.The state parameter must be non-empty and should be a single-use token generated specifically for a given request. It is important that the state parameter is impossible to guess, associated with a specific request, and used once. Use state for CSRF protection.
scopeYesInbound.Write, Order.Write, Product.Write, Inbound.Read, Order.Read, Product.Read, CalculatorA comma-separated list of scopes (permissions) the application requests. Example: Inbound.Write,Order.Write,Product.Read.

User Authorization

When you open the authorization link in a browser, you will be prompted to enter your account credentials. After logging in, the authorization screen will be displayed. If you do not have a Cloud account, you can use a test account provided in the testing tool to simulate the login process. Once logged in with the test account, re-open the authorization link to directly access the authorization interface.

User Authorization

Receiving the Authorization Code

Once the user completes the authorization process, the ZhenHub Open Platform will redirect to your specified callback URL with an authorization code. Your application should then use this code to request an access token.

Receive Authentication Code

Note: The authorization code is valid for five minutes and can be used only once. Once it expires, you will need to restart the authorization process to obtain a new code.

Get Token Using Authorization Code

Use the authorization code to obtain an access token.

Test environment: POST

Production environment: POST

Body

ParameterRequired?Example ValueDescription
client_idYeszhenhub_********8stMThe Client Key of your application.
redirect_uriYesYour app's redirect URI.The redirect URI provided during app creation. This must exactly match the one registered in your application settings.
response_typeYescodeThe type of authorization being requested. Use the fixed value "code".
scopeYesInbound.Write, Order.Write, Product.Write, Inbound.Read, Order.Read, Product.Read, CalculatorThe permissions your application is requesting. Multiple scopes are separated by commas.
codeYes********T0zzThe authorization code returned to the callback URL after the user authorizes the app.
client_secretYes********hG66The client secret associated with your application.
Body
json
{
   "client_id": "zhenhub_********8stM",
   "response_type": "code",
   "redirect_uri": "https://*****.com",
   "scope": "Inbound.Write,Order.Write,Product.Write,Inbound.Read,Order.Read,Product.Read,Calculator",
   "code": "********T0zz",
   "client_secret": "********hG66"
}

Response

ParameterExample ValueDescription
access_tokenzhenhub_********d4TBThe access token returned by the server. Use this token to access ZhenHub Open API resources.
expires_in7199 | -1The token's validity period in seconds. -1 indicates that the token does not expire.
client_idzhenhub_h***********WhwThe Client Key of your application.
scopeInbound.Write, Order.Write, Product.Write, Inbound.Read, Order.Read, Product.Read, CalculatorThe list of scopes (permissions) granted for this access token.
openid6469735808173060The unique identifier of the authorized user.

Using Access Token

Include your Access-Token and Client-Id in the request headers when calling any ZhenHub API.

Header

json
{
   "Client-Id": "zhenhub_********8stM",
   "X-Access-Token": "YOUR_AUTHORIZATION"
}