As showcased on the calendly demo app link is there any way create access token and refresh token on server side only, because as per their Documentation it is not listed anywhere.
I want to achieve something similar.
demo app code:
const OAuth2Strategy = require('passport-oauth2').Strategy;
const strategy = new OAuth2Strategy(
{
authorizationURL: CALENDLY_AUTH_BASE_URL + '/oauth/authorize',
tokenURL: CALENDLY_AUTH_BASE_URL + '/oauth/token',
clientID: CLIENT_ID,
clientSecret: CLIENT_SECRET,
callbackURL: REDIRECT_URI
},
async (accessToken, refreshToken, _profile, cb) => {
const calendlyService = new CalendlyService(accessToken, refreshToken);
const userInfo = await calendlyService.getUserInfo();
try {
const result = await User.findOrCreate({
accessToken,
refreshToken,
calendlyUid: userInfo.resource.uri
});
cb(null, { id: result.id });
} catch (e) {
console.error(e);
cb();
}
}
);
My implementation:
const OAuth2Strategy = require('passport-oauth2').Strategy;
const strategy = new OAuth2Strategy(
{
authorizationURL: CALENDLY_AUTH_BASE_URL + '/oauth/authorize',
tokenURL: CALENDLY_AUTH_BASE_URL + '/oauth/token',
clientID: CLIENT_ID ,
clientSecret: CLIENT_SECRET,
callbackURL: REDIRECT_URI,
},
async (accessToken, refreshToken, _profile, cb) => {
// console.log(IArguments)
console.log('async func called');
console.log(accessToken, refreshToken);
try {
cb(null,this.getRequestConfiguration(accessToken, refreshToken));
} catch (e) {
console.error(e);
cb();
}
}
);
In the response I am getting undefined for accessToken, refreshToken.