Using JS SDK in your application
All the Zoho CRM APIs are authenticated with OAuth2 standards, so it is mandatory to register and authenticate your client app with Zoho.
JavaScript SDK can be incorporated in two ways:
- Integrating JS SDK via Webapps.
- Using JS SDK on your own application.
1. Integrating JS SDK via Webapps
Follow the given steps for Integrating JS SDK:
- Register the client from CRM UI and note the client ID
- Create a new project using the command zet init via terminal/command line. Choose the option Catalyst and give the project name.
- A new folder will be created with the project name. Inside that, there will be a file plugin_manifest.json. Update the client ID in that file and the required scopes to be used in the web app.
- Under the project folder, there will be another folder named app. This will act as the base.
- Include the zcrmsdk.js file (available in app folder) and use it in your HTML files.
a. For Webapps Integration:
- After the development, run the command zet pack from the project base folder and upload it in CRM UI.
Note : Only one app can be uploaded for each client. While updating with the new app, the old one has to be deleted. Also, the redirect url will be changed. - To know the redirect URL, Initializer.store.getToken(token) function has to be accessed from web app. It will redirect to accounts.zoho.com/oauth/v2/auth along with a parameter 'redirect_uri'.
- Configure it in https://api-console.zoho.com. For eg: If the redirect_uri is "https://99000000223015.zappscontents.com/appfiles/99000000223015/1.0/1dd62561c00429f2c4970bf4f2b4dc09142d08b6949a17a5c3388f30851ec9cf/redirect.html", then the Authorized redirect URIs is "https://99000000223015.zappscontents.com/appfiles/99000000223015/1.0/1dd62561c00429f2c4970bf4f2b4dc09142d08b6949a17a5c3388f30851ec9cf/redirect.html"
- The JavaScript Domain is "https://99000000223015.zappscontents.com"
b. To test it in local machine using web framework:
- Create a redirect.html page within the app folder. The code for redirect.html has been provided below.
- Run it using the zet run via terminal/command line.>
- Enter 127.0.0.1:{your_port_number} (for eg. 127.0.0.1:5000) in the browser's address bar and select the app_file.html
- It will redirect to accounts.zoho.com/oauth/v2/auth along with a parameter redirect_uri. Configure it in https://api-console.zoho.com/
- If the page successfully redirects to the redirect.html page then the app works as intended.
- Once the token is set for the first time, the page will be reloaded.
2. Using JS SDK on your own application.
- Create a redirect.html page for your application.
- Set up your own web server and authorize the SDK.
- You can then use the SDK in your own application.
CDN Url : https://static.zohocdn.com/zohocrm/v2.0/sdk/4.0.0/sdk.js