Basic HTTP Authentication

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.

Step 1 Obtain a Certificate ID and Certificate Key

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.

Step 2 Generate a Token

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
	// 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")));

Step 3 HTTP Authentication

Format of the token field in the HTTP request header: Basic base64IDSecret.

Sample code:

  • Java
	// Java
	// Send HTTP request
	Request request = new Request.Builder()
	...
		// Fill the obtained token field in the beginning of HTTP request
		.addHeader("token", "Basic base64IDSecret")
	...

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top