Requesting an Access Token
Prerequisites: Nexoya client ID and client secret. If you don't have these, check out introduction page on how to obtain them.
To obtain an access token, make a POST request to the https://login.nexoya.io/oauth/token endpoint. The request body must include the grant_type set to client_credentials, along with the client ID and client secret of your application.
bash
#!/bin/bash
# Replace with your actual client ID, client secret, and audience
APP_CLIENT_ID="YOUR_CLIENT_ID"
APP_CLIENT_SECRET="YOUR_CLIENT_SECRET"
APP_AUDIENCE="YOUR_AUDIENCE"
curl -X POST "https://login.nexoya.io/oauth/token" \
-H "Content-Type: application/json" \
-d '{
"client_id": "'"$APP_CLIENT_ID"'",
"client_secret": "'"$APP_CLIENT_SECRET"'",
"audience": "'"$APP_AUDIENCE"'",
"grant_type": "client_credentials"
}'js
fetch('https://login.nexoya.io/oauth/token', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
client_id: process.env.APP_CLIENT_ID,
client_secret: process.env.APP_CLIENT_SECRET,
audience: process.env.APP_AUDIENCE,
grant_type: 'client_credentials',
}),
}).then(handleResponse);
function handleResponse(response) {
if (response.statusCode == 200) {
console.log(response.body.access_token);
}
}grant_type- Must be set toclient_credentials.client_id- The client ID of your application.client_secret- The client secret of your application.
The response will contain an access_token field with a JWT token. With this token, you can make authenticated requests to the Nexoya API.
