Get Bearer Token
To access the API, users must authenticate and obtain a bearer token. The bearer token acts as a form of authorization, granting access to protected resources. Follow the steps below to generate a bearer token.
Open the Authentication Endpoint URL: Access the authentication endpoint URL in a web browser or a tool like Postman.
URL:
<Virtana URL>/authorization/oauth/token?grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>
Example 4. Authorization Endpoint URL:~$ curl --location 'https://app.cloud.virtana.com/authorization/oauth/token' --form 'grant_type="client_credentials"' --form 'client_id="<client_id>"' --form 'client_secret="<client_secret>"'
To get the client_id and client_secret, refer Generate OAuth Credentials .
Provide Authentication Credentials: Provide the required authentication credentials, such as the client ID and client secret.
Submit the Authentication Request: Send the authentication request to the API server.
To retrieve an OAuth bearer token, use the /authorization/oauth/token endpoint. This endpoint supports various grant types and parameters.
Request Parameters
grant_type*: The grant type for the OAuth token request. Example: client_credentials
client_id*: The OAuth client ID. Example: 283gtr802edxxxx033b41dfa761cxxxxx
client_secret*: The OAuth client secret. Example: 3gfr2131dbbxxx1145f9xvbbndjdd
Receive the Bearer Token: If the request is successful, the server returns a JSON response containing the bearer token.
Copy or Note the Bearer Token: Copy the bearer token from the response or securely note it down.
Example
Request
GET /authorization/oauth/token?grant_type=client_credentials&client_id=<client_id>&client_secret=<client_secret>
Response
{ "access_token": "eyJhbGciOiJIUzI1NiIxxxxxxxxx....", "refresh_token": "eyJhbGciOiJIUzI1NiIsInRxxxxxxxxx....", "expires_in": 43xxx, "scope": "Scope", "token_type": "Bearer" }
Use the Bearer Token in Subsequent Requests: Utilize the bearer token in the Authorization header of subsequent API requests, prefixing it with 'Bearer' (e.g., 'Authorization: Bearer [token]'). This token grants access to the API's protected endpoints and resources.