getOauthInfo
This method returns a simple object containing all necessary OAuth values. This method provides developers with a safe and secure way to present to the framework values that are typically considered private, for example a client secret. These values are often stored in environment variables or in a vault.
Input parameters
None.
Return value(s)
This method should return an associative array with the following keys and values:
Key | Value |
---|---|
clientId |
The client ID of the application registered with the CRM provider, used to call the CRM's API. |
clientSecret |
The client secret of the application registered with the CRM provider. |
accessTokenUri |
The API endpoint used to retrieve the access token from the CRM provider. |
redirectUri |
The redirect URI registered with the CRM provider. |
Example
{
'clientId': 'xxx-xxxx-xxxxxxxxxx-xxxx',
'clientSecret': 'xxxxxxxx-xxxxxxxxxxxxxxxxxx',
'accessTokenUri': 'https://auth.crm.com/token',
'redirectUri': 'https://ringcentral.github.io/ringcentral-embeddable/redirect.html'
}
Reference
// Choose 1 of the following 3 functions, delete the rest. getBasicAuth is enabled just for testing
// CHOOSE: If using apiKey auth
function getBasicAuth({ apiKey }) {
return Buffer.from(`${apiKey}:`).toString('base64');
}
exports.getBasicAuth = getBasicAuth;
// CHOOSE: If using OAuth
// async function getOauthInfo() {
// return {
// clientId: process.env.TEST_CRM_CLIENT_ID,
// clientSecret: process.env.TEST_CRM_CLIENT_SECRET,
// accessTokenUri: process.env.TEST_CRM_TOKEN_URI,
// redirectUri: process.env.TEST_CRM_REDIRECT_URI
// }
// }
// exports.getOauthInfo = getOauthInfo;
// CHOOSE: If using OAuth somehow uses query not body to pass code
// function getOverridingOAuthOption({ code }) {
// return {
// query: {
// grant_type: 'authorization_code',
// code,
// client_id: process.env.TEST_OAUTH_CRM_CLIENT_ID,
// client_secret: process.env.TEST_OAUTH_CRM_CLIENT_SECRET,
// redirect_uri: process.env.TEST_OAUTH_CRM_REDIRECT_URI,
// },
// headers: {
// Authorization: ''
// }
// }
// }
// exports.getOverridingOAuthOption = getOverridingOAuthOption;
async function getOauthInfo() {
return {
clientId: process.env.PIPEDRIVE_CLIENT_ID,
clientSecret: process.env.PIPEDRIVE_CLIENT_SECRET,
accessTokenUri: process.env.PIPEDRIVE_ACCESS_TOKEN_URI,
redirectUri: process.env.PIPEDRIVE_REDIRECT_URI
}
}