Get IAM Access Token

Get IAM Access Token

Authorization

To use the secured inference endpoint, users will use the client ID and the client secret keys to be authorized via the authorization server (https://iam.api.greennode.ai/accounts/v2/auth/token) using the OAuth2 method.

To get the keys, go to GreenNode AI Cloud IAMcreate a service account to use the secured inference endpoint of the product. Accessing here to understand how to create a Service Account

Header

  1. 'Authorization': 'Basic Base64(clientID:clientSecret)'
    'Content-Type': 'application/x-www-form-urlencoded'
Request body
  1. 'grant_type': 'client_credentials'
Response
  1. 'token_type': 'Bearer'
    'access_token': '{IAM_ACCESS_TOKEN}
    'expires_in': 36000
cURL Example
  1. curl -X POST "<https://iam.api.greennode.ai/accounts/v2/auth/token>" \\
         -H "Authorization: Basic $(echo -n 'clientID:clientSecret' | base64)" \\
         -H "Content-Type: application/x-www-form-urlencoded" \\
         -d "grant_type=client_credentials"

Python Example

  1. import requests
  2. import base64

  3. # Client credentials
  4. client_id = "clientID"
  5. client_secret = "secretId"

  6. # Encode the credentials in Base64
  7. credentials = f"{client_id}:{client_secret}"
  8. encoded_credentials = base64.b64encode(credentials.encode()).decode()

  9. # Headers
  10. headers = {
  11. "Authorization": f"Basic {encoded_credentials}",
  12. "Content-Type": "application/x-www-form-urlencoded",
  13. }
  14. # Data
  15. data = {
  16. "grant_type": "client_credentials"
  17. }

  18. # Send POST request
  19. url = "<https://iam.api.greennode.ai/accounts/v2/auth/token>"
  20. response = requests.post(url, headers=headers, data=data)

  21. # Print response
  22. print(response.json()) # Assuming the response is in JSON format​

If the credentials are authorized, an access_token will be returned. Users will use this access_token to access resources from the resource server.


    • Related Articles

    • Create a Full Access IAM Policy

      A Full Access policy grants an IAM entity (user, group, or service account) unrestricted permissions to perform any action on all resources within your Greennode AI Platform account. While convenient, such policies should be used with caution due to ...
    • What is IAM?

      In this section, we'll cover the basics of Identity and Access Management (IAM) and how you can start managing access to your cloud resources securely. Identity and Access Management (IAM) is a crucial security tool in cloud computing. It focuses on ...
    • Attaching Your New Policy to an IAM User Account

      Now that you've created your IAM policy, it's time to assign it to an IAM user account. This will grant the user the permissions defined in the policy. Prerequisites You have already created an IAM user account. You have created the IAM policy you ...
    • Create an endpoint

      After training and registering the model, the online prediction component enables the deployment and serving of models to make real-time predictions or inferences on new data. This component provides endpoints or APIs that can be integrated into ...
    • Getting Started

      Step 1: Access the IAM Console Open your web browser and go to the IAM Console URL: {TBD} Log in as the Root User or a User Account with appropriate permissions. You'll need to provide your username/email and password. After logging in, you'll see ...