Authentication
Generating API Access Token
In order to authenticate and be granted authorization to access the ADMA Solution Inference APIs, clients need to generate a JWT access token. Please consult the ADMA generate access token for complete documentation.
In order to generate the token, you will need the following parameters configured in your request.
| Parameter | Description | 
|---|---|
| Tenant ID | Tenant ID in Azure AD generated in the app registration for accessing ADMA APIs | 
| Client ID | The application (service principal) ID of the application you registered for accessing ADMA APIs | 
| Client Secret | The secret generated for the application you registered for accessing ADMA APIs. | 
Here is how you would configure the request to generate an access token:
- cURL
- Python
- JavaScript
const axios = require('axios')
const CLIENT_ID = 'YOUR_CLIENT_ID'
const CLIENT_SECRET = 'YOUR_CLIENT_SECRET'
const TENANT_ID = 'YOUR_ADMA_TENANT_ID'
const endpoint = `https://login.microsoftonline.com/${TENANT_ID}/oauth2/token`
const headers = {'Content-Type': 'application/x-www-form-urlencoded'}
const data = {
    'grant_type': 'client_credentials',
    'client_id': CLIENT_ID,
    'client_secret': CLIENT_SECRET,
    'resource': 'https://farmbeats.azure.net'
}
axios.post(endpoint, data, headers)
    .then(res => console.log(res.data))
    .catch(console.error)
import requests
CLIENT_ID = 'YOUR_CLIENT_ID'
CLIENT_SECRET = 'YOUR_CLIENT_SECRET'
TENANT_ID = 'YOUR_ADMA_TENANT_ID'
endpoint = 'https://login.microsoftonline.com/{TENANT_ID}/oauth2/token'.format(TENANT_ID=TENANT_ID)
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
data = {
    'grant_type': 'client_credentials',
    'client_id': CLIENT_ID,
    'client_secret': CLIENT_SECRET,
    'resource': 'https://farmbeats.azure.net'
}
response = requests.post(endpoint, json=data, headers=headers)
print(response.json())
  curl -X POST -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'grant_type=client_credentials&client_id={CLIENT_ID}&resource=https://farmbeats.azure.net&client_secret={CLIENT_SECRET}' \
  https://login.microsoftonline.com/{TENANT_ID}/oauth2/token
The response should look like:
{
  "token_type": "Bearer",
  "expires_in": "3599",
  "ext_expires_in": "3599",
  "expires_on": "1622530779",
  "not_before": "1622526879",
  "resource": "https://farmbeats.azure.net",
  "access_token": "eyJ0eXAiOiJKV1QiLC......tpZCI6InZhcF9"
}