unAuthorize
It is to remove user data from our database when user chooses to log out. Some CRMs have token invalidation mechanism, if so, please implement that as well.
Request parameters
Parameter | Description | |
---|---|---|
user |
An object describing the Chrome extension user associated with the action that triggered this interface. |
Return value(s)
Parameter | Description |
---|---|
returnMessage |
message , messageType and ttl |
Example
{
returnMessage:{
message: 'Successfully unauthorized',
messageType: 'success', // 'success', 'warning' or 'danger'
ttl: 30000 // in miliseconds
}
}
Reference
}
]
}
],
ttl: 3000
}
}
}
//---------------------------------------------------------------------------------------------------
//---CHECK.1: Open db.sqlite (might need to install certain viewer) to check if user info is saved---
//---------------------------------------------------------------------------------------------------
}
async function unAuthorize({ user }) {
// -----------------------------------------------------------------
// ---TODO.2: Implement token revocation if CRM platform requires---
// -----------------------------------------------------------------
// const revokeUrl = 'https://api.crm.com/oauth/unauthorize';
// const revokeBody = {
// token: user.accessToken
// }
// const accessTokenRevokeRes = await axios.post(
id: '1',
type: 'text',
text: `Pipedrive was unable to fetch information for the currently logged in user. Please check your permissions in Pipedrive and make sure you have permission to access and read user information.`
}
]
}
],
ttl: 3000
}
}
}
}
async function unAuthorize({ user }) {
const revokeUrl = 'https://oauth.pipedrive.com/oauth/revoke';
const basicAuthHeader = Buffer.from(`${process.env.PIPEDRIVE_CLIENT_ID}:${process.env.PIPEDRIVE_CLIENT_SECRET}`).toString('base64');
const refreshTokenParams = new url.URLSearchParams({
token: user.refreshToken
});
const refreshTokenRevokeRes = await axios.post(
revokeUrl,
refreshTokenParams,
{
headers: { 'Authorization': `Basic ${basicAuthHeader}` }
});
const accessTokenParams = new url.URLSearchParams({
token: user.accessToken
});
const accessTokenRevokeRes = await axios.post(
revokeUrl,