Request token

To use our GraphQL API you will first need to request a token. You will receive a CLIENT_ID and CLIENT_SECRET by contacting Pluvo.


Authorize URL: https://[organisation-name].pluvo.co/oauth/token/


Node.js Example

For this example we use the npm packages qs and axios

const qs = require('qs');
const axios = require('axios').default;
const OAUTH_AUTHORIZE_URL = 'https://[organisation-name].pluvo.co/oauth/token/';
const CLIENT_ID = 'client-id';
const CLIENT_SECRET = 'client-secret';
const scope = [
'users.read',
'users.write',
'trainings.read',
'trainings.write',
'events.read',
'events.write',
'groups.read',
'groups.write',
].join(' ');
// Make sure to use application/x-www-form-urlencoded as `Content-Type` header.
const requestConfig = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
};
const requestData = qs.stringify({
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
grant_type: 'client_credentials',
scope,
});
axios
.post(OAUTH_AUTHORIZE_URL, requestData, requestConfig)
.then((response) => {
const data = response.data;
console.log('accessToken', data.access_token);
})
.catch((error) => {
console.error('Got an error response from the API', error.message);
});