Generate a custom client token to authorize user access
Cloud Scale’s Authentication component allows you to implement a third-party authentication service of your preference for your Catalyst application. The authorization and validation of the end-user is handled by the third-party service, and the data is passed on to Catalyst.
-
Since you are implementing a third-party authentication service, it is understood that the security infrastructure of your application is contingent on the efficiency of the third-party service that you have chosen.
-
To enable a third-party authentication in your Catalyst application, you must ensure that you have enabled Public Signup in the console.
When a user is re-directed from a third-party service after being authenticated, their credentials must be passed to an authentication function that you code in Java, Node.js, or Python. This function will generate a Catalyst server-side token, which will be passed to client-side code given below. You must incorporate this code into your web client logic.
A sample code to process the custom server token and generate a JSON Web Token token (JWT) to authenticate the user is given below.
copy
<script src="https://static.zohocdn.com/catalyst/sdk/js/4.0.0/catalystWebSDK.js"></script>
<script src="/__catalyst/sdk/init.js"></script>
<script>
catalyst.auth.signinWithJwt(getCustomTokenCallback);
function getCustomTokenCallback(){
return fetch("{domain}/server/{function_name}/execute") //function url to get the generated custom token
.then(resp => resp.json()
.then(resp => {
return new Promise((resolve, reject) => {
resolve({
client_id : "********",
scopes : "ZOHOCATALYST.tables.rows.ALL,ZOHOCATALYST.cache.READ",
jwt_token : "*********"
});
});
}))
}
</script>
Yes
No
Send your feedback to us