Generating an OAuth 2 token for Cliq

Generating an OAuth 2 token for Cliq

OAuth 2.0 protocol is a way to authorize and authenticate API requests. It allows third party application developers to let their users access and use the resources securely. This post will walk you through the steps involved in generating an OAuth 2 token for Cliq.

Follow the steps given below to know more on how to generate an OAuth 2 token for Cliq.


Step 1: Generate Client id and Client secret 


You will need to register your client app before getting started. A registered client app will be assigned a Client ID and a Client Secret which will be used in the OAuth flow. The Client ID is a public identifier for applications. Although it is public, it is best that it is not guessable to prevent attacks on the arbitrary applications possibly. On the other hand, the Client Secret is a secret only known to the application and the authorization server. 

  1. Visit the Cliq developer console and register your client application and include the following details
  • Client Name : The name of the application that you want to register with. This name will be shown in the consent displayed to the user while granting access to the required scopes.
  • Client Domain: A domain name to be used in the URL to identify your brand name uniquely.
  • Authorized redirect URL's: Callback URL to which user's will be redirected upon successful authorization.
      2. Click on the Create button.

Step 2: Authorization by generating a grant token 


The second step is to redirect the user of the client application to an authorized endpoint (https://accounts.zoho.com/oauth/v2/auth). Cliq will ensure the consent for the permissions that your app requests. In this step, after the consent is obtained, Cliq will redirect to your app along with the code that can be used in generating an Access token.

Type in the URL along with the mandatory parameters given below.

https://accounts.zoho.com/oauth/v2/auth?scope={scope}&client_id={client_id}&state=5466400890088961855&response_type=code&redirect_uri={redirect_uri}&access_type=offline 

Note:Mandatory parameters are indicated with a *.

Parameter
Description 
scope*
Scope helps you access application data. 
You can include multiple scopes by separating them with a comma.
For example (ZohoCliq. Channels.READ,ZohoCliq.Channels.UPDATE). 
client_id*
The client-id obtained while registering your application.
state
This parameter is used to maintain the state between the request and callback.
response_type*
The value of the param response_type should always be code.
redirect_uri*
It specifies the URL to which the page is redirected along with the code when the user grants an access.
access-type
Enter the access type as online or offline. 
online- To generate only the Access token.
offline- To generate both the Access and the Refresh Tokens.

Step 3: Generating Access and Refresh tokens 

The value of the code parameter obtained in the previous step will be used in generating the Access and the Refresh token. 
Make a POST request to the following URL along with the parameters mentioned below. 

https://accounts.zoho.com/oauth/v2/token?code={code}&grant_type=authorization_code&scope={scope}&client_id={client_id}&client_secret={client_secret}&redirect_uri={redirect_uri} 


Parameter
Description
code*
The authorization code obtained while generating the grant token.
client_id*
The client-id obtained while registering the application.
client_secret*
The client-secret obtained during the application registration.
redirect_uri*
Include the redirect URI mentioned while registering your client application.

grant_type*

authorization_code
scope
Mention the scope for your extension.

Note: The generated code is valid for only one minute.
On making a successful request, you will receive the following response
  1. {
  2. "access_token": "1000.365170ed0e63c47bf759439c1897fee0.7c3a098808532004faba21ff291ec296",
  3. "refresh_token": "1000.368e377f885b7e2ff696479625b3e150.6cad850717614193bddbf489b6a437d6",
  4. "api_domain": "https://www.zohoapis.com",
  5. "token_type": "Bearer",
  6. "expires_in": 3600
  7. }
  1. access_token - Access token to access Zoho Cliq APIs.
  2. refresh_token - Refresh tokens to generate new Access tokens.
  3. api_domain - Domain name of the API. Use this domain in your requests to make API calls to Zoho Cliq.
  4. token_type - Type of the token obtained. Bearer in this case.
  5. expires_in - Time in milliseconds after which the token expires.

Note: 1. Each access token is valid only for an hour
2. Refresh tokens do not expire and can be used any number of times to generate new access tokens. 

Step 4: Generating the Access token from the Refresh token

Now to generate a new Access token, use the refresh token from the previous step. 
Make a POST request to the given URL along with the parameters mentioned below.

https://accounts.zoho.com/oauth/v2/token?refresh_token={refresh_token}&grant_type=refresh_token&scope={scope}&client_id={client_id}&client_secret={client_secret}&redirect_uri={redirect_uri}

Parameter

Description
client_id*
The client_id obtained while registering your application.
client_secret*
The client_secret obtained while registering your application.
redirect_uri
The redirect uri mentioned during the client registration.

grant_type*

refresh_token
refresh_token*
The refresh token obtained in the previous step.

scope*

The suitable scope for your extension.

Note: A user in an organization can have a maximum of 20 refresh tokens and each refresh token can have a maximum of 30 active Access tokens.



So that was all about generating an OAuth 2 token for Cliq. In case of any queries please do comment below. We'd be happy to assist you.

Regards,
Divya P 
Cliq













    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      • Sticky Posts

      • Convert a message on Cliq into a task on Zoho Connect

        Message actions in Cliq are a great way to transform messages in a conversation into actionable work items. In this post, we'll see how to build a custom message action that'll let you add a message as a task to board on Zoho Connect. If you haven't created
      • Cliq Bots - Post message to a bot using the command line!

        If you had read our post on how to post a message to a channel in a simple one-line command, then this sure is a piece of cake for you guys! For those of you, who are reading this for the first time, don't worry! Just read on. This post is all about how
      • Cliq Bots - How to make a bot respond to your messages?

        Bots are just like your buddies with whom you can interact. They carry out your tasks, keep you notified about your to-dos and come in handy when you need constant updates from a third party application.  So, how can you make your bot respond to a message? The bot message handler is a piece of code triggered when a message is sent to the bot. Message handlers help you customise your bot responses to make it look conversational. The message input from the user can be either a string or an option selected
      • Cliq Bots - Get notifications about any action on an application with the incoming webhook handler!

        Webhooks can be used to get notified about events happening in other applications inside Cliq. All bots in Cliq have their own incoming webhook endpoint. This makes it simple to post messages to the bot from external applications. Unlike the send message
      • The Slash Command Series - Types of Command Suggestions

        Hi Everybody! I hope you guys tried the /zdocs command and now have an idea of how command suggestions with click to execute work. If you have no clue of what command suggestion is, I recommend you to take a look at all the Slash Command Series posts, especially the one on Command Suggestions ! This post is all about the different types of command suggestions.  Customise your command suggestions  Did you know you could customise your command suggestion list with a title, description, image? Well,

      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方