Using OAuth authentication with your Zendesk application

Summary:

This article describes the step-by-step process of generating an Access token for the Zendesk OAuth Authentication for the webMethods.io.

Prerequisites:

  • User needs to have a trail or a paid subscription for the Zendesk.
  • Working webMethods.io Integration cloud tenant.

Contents:

  • Registering your application with Zendesk for OAuth authentication.
  • Implementing an OAuth authorization flow in your application.
Note:
Any coding or configuration examples provided in this document are only examples and are not intended for use in a production system without verification. The example is only done here to better explain and visualize the possibilities.

Registering your application with Zendesk.

Steps:

    1. User needs to sign up for the Zendesk free trail: https://www.zendesk.com/register/#step-1

    2. After successfully registering the trails from Zendesk, the user will be allocated a Zendesk tenant and the trail is valid for 13 days . the user will receive the tenant details via email.

    3. In Zendesk Support, click Manage(settings icon).

    4. Select the API in the channels category.

    5. Agree with the terms & conditions then click on the “Get started” button.

    6. Zendesk API page will open, then click the “OAuth Clients” tab on the channels/API page and then click the plus icon (+) on the right side of the client list.

    7. The next page will request the user to fill the details for the app.

    8. After filling the necessary details, click on the “Save” button. A secret_key will generate, note it down and keep it safe as we required this “secret_key” at the time of generating the “access_token”. The value present in the Unique Identifier is your “client_id”.

Implementing an OAuth authorization flow in your application.

Steps:

    1. First, your application has to send the user to the Zendesk authorization page. The page asks the user to authorize your application to access Zendesk on their behalf. After the user makes a choice, Zendesk sends the choice and a few other bits of information back to your application.

Example GET request:

https://{subdomain}.zendesk.com/oauth/authorizations/new?response_type=code&redirect_uri={your_redirect_url}&client_id={your_unique_identifier}&scope=read%20write

    2. The user needs to substitute the values for the above URL and run this URL in the web browser. It will ask the user to allow for the necessary permissions. Click on the “Allow” button.

    3. It will generate the “Code” in the browser. Copy the code and save it as we need this code at the time of generating the “access_token”.

    4. Now, our application received an authorization code from Zendesk in response to the user granting access, your application can exchange it for an access token. To get the access token, make a POST request to the following endpoint. we will use the “Postman” client to generate the “access_token” for the Zendesk.

POST  https://{subdomain}.zendesk.com/oauth/tokens

Content-type: application/json

Query params:

grant_type: authorization_code

code: <code we obtain in browser>

client_id: Unique Identifier

client_secret: secret we obtain above.

redirect_uri: redirect URL for the App.

Scope: provide the scope "read" or "write"

Please refer to the below screenshot for more clear vision. we have successfully generated the access_token for the Zendesk.