The RESTful API must undergo Basic HTTP authentication. You need to generate a token and fill in the HTTP request header's token field. This section introduces how to generate a token and perform HTTP authentication.
In the code, enter your certificate ID (restfulId) and certificate key (restfulSecret) information.
Here's how to get a certificate ID and certificate key:
Log in to your Jocloud My Center. Click the account name in the upper right corner and select the API Certificate page from the drop-down list.
Notes:
The certificate ID and certificate key are only for accessing the RESTful API.
Token is a Base64 algorithm-encoded idSecret. Use your certificate ID (restfulId) and certificate key (restfulSecret) to generate a token. In this sample, the token is base64IDSecret.
Sample code:
// Java
// Fill in the certificate ID and key gotten in My Center on the portal website
String plainIDSecret = "restfulId:restfulSecret";
// base64IDSecret is your token value
String base64IDSecret = new String(Base64.encodeBase64(plainIDSecret.getBytes("UTF-8")));
Format of the token field in the HTTP request header: Basic base64IDSecret.
Sample code:
// Java
// Send HTTP request
Request request = new Request.Builder()
...
// Fill the obtained token field in the beginning of HTTP request
.addHeader("token", "Basic base64IDSecret")
...