Back to website: www.pluvo.com
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.com/oauth/token/
Note: The trailing slash at the end of the URL is essential
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.com/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',
'extra_categories.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);
});