Zoho CRM V2 Authenticate an Element

You can authenticate with Zoho CRM V2  to create your own instance of the Zoho CRM V2 element through the UI or through APIs. Once authenticated, Zoho CRM V2 can use the element instance to access the different functionalities offered by the Zoho CRM V2 platform.

Authenticate Through the UI

Use the UI to authenticate with Zoho CRM V2  and create an element instance. Because you authenticate with Zoho CRM V2 via OAuth 2.0, all you need to do is add a name for the instance. After you create the instance, you'll log in to Zoho CRM V2 to authorize Cloud Elements access to your account. For more information about authenticating an element instance, see Authenticate an Element Instance (UI)

After successfully authenticating, we give you several options for next steps. Make requests using the API docs associated with the instance, map the instance to a virtual data resource, or use it in a formula template.

Authenticate Through API

Authenticating through API is a multi-step process that involves:


1
Redirect URL




2
Authenticate Users




3
Authenticate Instance


Getting a Redirect URL


1
Redirect URL




2
Authenticate Users




3
Authenticate Instance


Use the following API call to request a redirect URL where the user can authenticate with the API provider. Replace {keyOrId} with the element key,zohocrmv2.

GET /elements/{keyOrId}/oauth/url?apiKey=<api_key>&apiSecret=<api_secret>&callbackUrl=<url>

Query Parameters

Query ParameterDescription
apiKeyThe key obtained from registering your app with the provider. This is the OAuth Client ID that you recorded in API Provider Setup.
apiSecretThe secret obtained from registering your app with the provider. This is the OAuth Client Secret that you recorded in API Provider Setup.
callbackUrlThe URL that will receive the code from the vendor to be used to create an element instance. This is the Callback URL that you noted at the end of API Provider Setup.

Example cURL

curl -X GET
-H 'Content-Type: application/json'
'https://api.cloud-elements.com/elements/api-v2/elements/zohocrmv2/oauth/url?apiKey=fake_api_key&apiSecret=fake_api_secret&callbackUrl=https://www.mycoolapp.com/auth'

Example Response

Use the oauthUrl in the response to allow users to authenticate with the vendor.

{
  "oauthUrl": "https://accounts.zoho.com/oauth2/auth?access_type=offline&approval_prompt=force&client_id=fake_api_key&redirect_uri=https://www.mycoolapp.com/auth&response_type=code&scope=https://www.zohoapis.com/auth/drive&state=zohocrmv2",
  "element": "zohocrmv2"
}

Authenticating Users and Receiving the Authorization Grant Code


1
Redirect URL




2
Authenticate Users




3
Authenticate Instance


Provide the response from the previous step to the users. After they authenticate, Zoho CRM V2 provides the following information in the response:

  • code
  • state
Response ParameterDescription
codeThe Authorization Grant Code required by Cloud Elements to retrieve the OAuth access and refresh tokens from the endpoint.
stateA customizable identifier, typically the element key (zohocrmv2) .
Note: If the user denies authentication and/or authorization, there will be a query string parameter called error instead of the code parameter. In this case, your application can handle the error gracefully.

Authenticating the Element Instance


1
Redirect URL




2
Authenticate Users




3
Authenticate Instance


Use the /instances endpoint to authenticate with Zoho CRM V2 and create an element instance. If you are configuring events, see the Events section.

Note: The endpoint returns an element token upon successful completion. Retain the token for all subsequent requests involving this element instance.

To create an element instance:

  1. Construct a JSON body as shown below (see Parameters):

    {
     "element":{
       "key": "zohocrmv2"
    },
      "configuration": {
        "oauth.api.secret": "xxxxxxxxxxxxxxx",
        "event.poller.refresh_interval": "15",
        "oauth.callback.url": "https://auth.cloudelements.io/oauth",
        "event.vendor.type": "polling",
        "api.base.url": "https://www.zohoapis.com",
        "oauth.scope": "ZohoCRM.users.all,ZohoCRM.org.all,ZohoCRM.modules.all,ZohoCRM.settings.all,ZohoCRM.bulk.ALL,ZohoFiles.files.ALL",
        "oauth.api.key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "oauth.base.url": "https://accounts.zoho.com",
        "event.notification.enabled": "false",
        "event.poller.configuration": "<EVENT_POLLER_CONFIGURATION>",
        "oauth.user.refresh_time": null,
        "oauth.user.refresh_token": null
      },
      "name": "<INSTANCE_NAME>",
      "eventsEnabled": null,
      "providerData": {
        "state": "zohocrmv2",
        "code": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "location": "us",
        "accounts-server": "https://accounts.zoho.com",
        "debug": false,
        "secret": "xxxxxxxxxxxxxxxxxxxxxxx"
      }
    }
  2. Call the following, including the JSON body you constructed in the previous step:
  3. POST /instances
    
    Note: Make sure that you include the User and Organization keys in the header. For more information, see Authorization Headers, Organization Secret, and User Secret.
  4. Locate the token and id in the response and save them for all future requests using the element instance.

Example cURL

curl -X POST 
  -H "authorization: User <USER_SECRET>, Organization <ORGANIZATION_SECRET>" \
  -H "content-type: application/json" \
  -d '{
  "name": "<INSTANCE_NAME>",
  "providerData": {
    "code": "<INSERT>"
  },
  "configuration": {
    "api.base.url": "https://www.zohoapis.com",
    "oauth.base.url": "https://accounts.zoho.com"
  },
  "tags": [
    "For Docs"
  ]
}

Parameters

API parameters not shown in Cloud Elements are in code formatting.

Note: Event related parameters are described in Events.
ParameterDescriptionData Type
'key'The element key.
zohocrmv2
string
Name
name
The name for the element instance created during authentication.Body
oauth.callback.urlThe Callback URL that was registered when creating credentials in your Zoho CRM V2 project. This is the Callback URL that you noted at the end of API Provider Setup.
oauth.api.keyThe OAuth Client ID from Zoho CRM V2. This is the Client ID that you noted at the end of API Provider Setup.string
oauth.api.secretThe OAuth Client Secret from Zoho CRM V2. This is the Client Secret that you noted at the end of API Provider Setup.string

Example Response

{
  "id": 123456,
  "name": "<INSTANCE_NAME>",
  "createdDate": "2019-09-24T12:59:36Z",
  "token": "6mT752lQuzz+dZYaQ9PMccEnuQTR3VjGZ8jrB4pjEHU=",
  "elementId": 1234,
  "tags": [
    "<TAGS>"
  ],
  "provisionInteractions": [],
  "valid": true,
  "disabled": false,
  "maxCacheSize": 0,
  "cacheTimeToLive": 0,
  "providerData": {
    "state": "zohocrmv2",
    "code": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "location": "us",
    "accounts-server": "https://accounts.zoho.com",
    "debug": false,
    "secret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  },
  "configuration": {
    "base.url": "xxxxxxxxxxxx",
    "event.notification.subscription.id": null,
    "event.notification.basic.username": "",
    "event.vendor.type": "polling",
    "pagination.type": "page",
    "oauth.callback.url": "https://auth.cloudelements.io/oauth",
    "event.notification.signature.key": null,
    "oauth.user.refresh_token": "xxxxxxxxxxxxxxxxxxxxxxxx",
    "oauth.user.refresh_interval": "3600",
    "oauth.token.revoke_url": "{oauth.base.url}/oauth/v2/token/revoke",
    "oauth.api.key": "********",
    "oauth.base.url": "https://accounts.zoho.com",
    "event.notification.enabled": "false",
    "allow.select.fields": "true",
    "oauth.api.secret": "********",
    "default.select.fields.map": null,
    "oauth.token.url": "{oauth.base.url}/oauth/v2/token",
    "pagination.max": "200",
    "event.notification.basic.password": "********",
    "oauth.scope": "ZohoCRM.users.all,ZohoCRM.org.all,ZohoCRM.modules.all,ZohoCRM.settings.all,ZohoCRM.bulk.ALL,ZohoFiles.files.ALL",
    "oauth.token.refresh_url": "{oauth.base.url}/oauth/v2/token",
    "oauth.user.token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "oauth.authorization.url": "{oauth.base.url}/oauth/v2/auth?access_type=offline&prompt=consent",
    "event.poller.refresh_interval": "15",
    "event.notification.callback.url": null,
    "api.base.url": "https://www.zohoapis.com",
    "oauth.user.refresh_time": "1569329977097",
    "event.poller.configuration": "{}",
    "oauth.basic.header": "true"
  },
  "authenticationType": "oauth2",
  "eventsEnabled": false,
  "externalAuthentication": "none",
  "organizationId": 1190,
  "accountId": 43739,
  "cachingEnabled": false,
  "traceLoggingEnabled": false,
  "userId": 53822,
  "element": {},
  "user": {
    "id": xxxxxxx
  }
}