ARTICLE

Generating an API Token

25 August 2020 by Rudy Setiawan

API token is useful to enable access to Cloud Raya API located in the API documentation. You can generate such token once you have generated an API key via this guidelines Generate API Key.

Please follow the steps below.

In our API Documentation, you need to send an authentication to the API gateway. This is to get your API token, in this case a “Bearer” Token.

Step 1: Sending a http post

Send a http POST to the URL https://api.cloudraya.com/v1/api/gateway/user/auth with a raw JSON Body that contains the app_key and secret_key found in API Gateway Management Page in the Cloud Raya Control Panel. The example raw JSON body is as follow.

{
    "app_key": "9a0bb2f3-4e2e-4e57-b340-ee36f3076515",
    "secret_key": "QLap0OqzMpRccfeDzAnSD8wqj4FPMlda"
}

Step 2: Obtaining a bearer token

The API Gateway will return a “bearer_token” that you can use to communicate with the API gateway. The figure below illustrates the response that you will get regarding the bearer token.

{
    "code": 200,
    "data": {
        "bearer_token": "eyJpdiI6IkhldHRZY0FoZjVaSXdYTEdp.....",
        "username": "the_username",
        "expired_at": "2020-08-20 14:43:27",
        "timezone": "UTC",
        "refresh_token": "eyJpdiI6InhFVVY4QmR2YlFF......."
    },
    "message": "success"
}

Step 3: Using the bearer token

You may use the “bearer_token” in your header as an “Authorization” with value “Bearer <token>” without the “<” or “>”

Remember, the token can expire. However, you can use the refresh token to get a new token. That way, you do not need to send another authentication to obtain a new token.

0 0 vote
Article Rating

Ready to Make Something Big?

Deploy in Cloud Raya