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 IAM, create a service account to use the secured inference endpoint of the product. Accessing here to understand how to create a Service Account
Header
'Authorization': 'Basic Base64(clientID:clientSecret)'
'Content-Type': 'application/x-www-form-urlencoded'
'grant_type': 'client_credentials'
'token_type': 'Bearer'
'access_token': '{IAM_ACCESS_TOKEN}
'expires_in': 36000
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
- import requests
- import base64
- # Client credentials
- client_id = "clientID"
- client_secret = "secretId"
- # Encode the credentials in Base64
- credentials = f"{client_id}:{client_secret}"
- encoded_credentials = base64.b64encode(credentials.encode()).decode()
- # Headers
- headers = {
- "Authorization": f"Basic {encoded_credentials}",
- "Content-Type": "application/x-www-form-urlencoded",
- }
- # Data
- data = {
- "grant_type": "client_credentials"
- }
-
- # Send POST request
- url = "<https://iam.api.greennode.ai/accounts/v2/auth/token>"
- response = requests.post(url, headers=headers, data=data)
- # Print response
- 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.