Authorizing User
- Get API_KEY and API_SECRET from Richpanel Apps => Custom Connector.
Use the below method to generate encrypted data for user (make sure this is happening in a secure place)
data = {
'id': '1234', // Required
'firstName': 'Adam',
'lastName': 'Smith',
'email': '[email protected]'
}
const crypto = require('crypto');
const encryptData = (data, secret) => {
const key = crypto.createHash("sha256").update(secret).digest('hex');
let iv = crypto.randomBytes(16);
let cipher = crypto.createCipheriv('aes-256-cbc', new Buffer(key).slice(0,32), iv);
let encrypted = cipher.update(JSON.stringify(data));
encrypted = Buffer.concat([encrypted, cipher.final()]);
return iv.toString('hex') + ':' + encrypted.toString('hex');
}
Authentication can be done in two ways using encrypted data
- Set encrypted value in
localStorage.rpMessengerAuth
- Set encrypted value in URL while loading helpcenter
Example:
https://richpaneldemo.customerdesk.io/?encryptedUserParams=<encrypted-data>
Note: Removing these values will logout the user.
Updated almost 3 years ago