Chat API tutorial: Generating an OAuth token (integrated Chat accounts)

Return to top
Have more questions? Submit a request

22 Comments

  • Hanlin Chen

    I can see if I don't use the code quick enough, I get an invalid_grant error

    However, I always get an access_denied error otherwise... Can anyone suggest which step I could have missed? (I am the admin of both Zendesk chat and support)

    Thanks

    1
  • Niall Colfer
    Zendesk team member

    Hi Hanlin,

    Thanks for letting us know. I see you have an open ticket with my colleague to troubleshoot further, we'll gather some details from you regarding your issue there.

    0
  • Jan Marowski

    Hi Niall,

     

    I have problem with final step. I'm getting:

    {{"description": "The method is not allowed for the requested URL.", "error": "Method Not Allowed"}}

    Can you tell me if this is some setting that I can set or this is what you have mentioned in beginning of this article in conditions?

     

    Thx

    0
  • Ruth Anne Dilig

    Hi,

    I understand that this procedure is for authorization code grant type. Can you also provide a tutorial on how I can get an access token with client_credentials grant type? I am using the curl command below which I found in https://developer.zendesk.com/rest_api/docs/chat/auth and I am getting an error: "invalid_client". Thanks

    curl https://www.zopim.com/oauth2/token \
      -H "Content-Type: application/x-www-form-urlencoded" \
      -d 'grant_type=client_credentials&client_id={your_client_id}&client_secret={your_client_secret}' \
      -X POST
    0
  • Ruth Anne Dilig

    Hello, I already solved this issue. I just wanna share the solution if grant_type is client_credentials. The client_type must be set to confidential to be able to get the access token

    0
  • ★Panayiotis Georgiou

    Hello,

    I have tried to connect to the api and still getting CORS problems


    Failed to load https://www.zopim.com/api/v2/chats: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://0e9272c4.ngrok.io' is therefore not allowed access.

    Can you tell me if this is some setting that I can avoid the CORS problems ?

     

    Thanks,

    P.

    0
  • Logan McNiece

    I am in the same boat as Hanlin Chen. I can get the the auth code via step #3, but no matter what I do I get "access_denied" for step #4. I also am an admin of both Zendesk chat and support. What could be causing this?

    Also, I'd advise updating your documentation at https://developer.zendesk.com/rest_api/docs/chat/chats to highlight this different authentication pattern. It is super confusing for anyone on an integrated Zopim-Zendesk account. I spent three hours trying to get this to work until accidentally stumbling on this thread via a google search.

    1
  • Logan McNiece

    Just a call out. I figured out the issue for my instance of the "access_denied", not sure if it was the same for Chen. I was not specifying localhost:8080 as my redirect.

    2
  • Hani Tanna

    hello... i got error that unsupported_grant_type

     

    0
  • Jim Williams

    I found this process was a little easier when I modified it as such:

    Step 1 - Request a token rather than a code using this URL:

    https://www.zopim.com/oauth2/authorizations/new?response_type=token&redirect_uri=http%3A%2F%2Flocalhost%3A8080&client_id=CLIENT_ID&scope=read%20write&subdomain=SUBDOMAIN

    Step 2 - Skipped.

    Step 3 - Get the token from the URL bar in the browser.  The URL in the bar will look similar to:

    localhost:8080/#access_token=IAdTnWBl8<REDACTED>qP4mYlRp8De34&token_type=Bearer&scope=read+write

    Only grab the value for access_token.

    Step 4 - Skipped.

    Step 5 - Use the access_token from Step 3 directly.

     

    Hopefully this will help to simplify the process.

    6
  • Yusuf Khan

    can anyone help me I am trying call

    curl https://rtm.zopim.com/stream/{resource} \
      -H "Authorization: Bearer {API access token}"

    initially, I tried with basic auth (adding id : password in the request) response was unauthorized

     

    then I generate access token with postman like in below screenshot

    and when call API with that access token then the response is 403 forbidden

    thanks you

    0
  • Antonino Tocco

    Hi all, I'm trying to get all my chats with /api/v2/chats. I have tried also zopim.com endpoints and {subdomain}.zendesk.com endpoint.

    Zopim give me cors error for header authorization and subdomain give me 404 for path /api/v2/chats.

     

    Can you please help me?

    0
  • Devan - Community Manager
    Zendesk Community Team

    Hello Antonino Tocco,

    I'll see if I can get a bit more visibility on this for you within the community. In the meantime, I've linked an article that goes into Chat API in more depth.

    Chat API Developer

    Best regards.

    0
  • Bryan - Community Manager
    Zendesk Developer Support

    Hi Antonino Tocco -- you definitely need to use the www.zopim.com as your domain prefix when calling Chat APIs.

    Can you give more context as to where you're making the API call from (examples: a Chat app inside the agent interface, a custom web page, etc).

    Also, can you make the call from the command line using cURL or from a tool such as Postman?

    0
  • Emile Cohen

    Hi everyone,

    I am deploying an OAuth2 flow for Zendesk Chat but I get a "unsupported_grant_type" error while requesting an authorisation_code in part 4. I made sure to respect the syntax grant_type= "authorisation_code". I do not know how to bypass this issue. Maybe there is something to activate when creating the client, but I do not see anything on Zendesk Chat interface. 

    Thanks !

    0
  • Bryan - Community Manager
    Zendesk Developer Support

    You might have a typo there Emile. Make sure it's "authorization_code" and not "authorisation_code" — the spelling is part of the OAuth standard and doesn't reflect regional spelling differences.

    0
  • Jayashankar R

    Hi, I have the same issue getting access token after getting authorization_code. I'm using this doc. Getting 401 {"error": "access_denied"}. Is there any issues with this API nowadays ?

    0
  • Bryan - Community Manager
    Zendesk Developer Support

    Hello Jayashankar R — the above article has the most detailed methods for obtaining Chat OAuth tokens. The above sections "Create the OAuth API client" and "Complete the OAuth implicit grant flow to get the token" are the easiest ways to get an access token manually. There have been no changes to these steps or APIs.

    If you're still running into issues, please contact Zendesk Customer Support, as there may be specifics of your personal account that need to be discussed.

    0
  • Lev

    hi, i followed the steps in the article and got an access token with no errors :D 

    but I seems cannot use this token to access the Conversation APi, i got invalid scope error, 

    I added a screen shot here for the error of scope 

    also this is how i get the access token 

    when i did this cURL call, I tried with scope = chat / scope= read write, i could get token no problem, but I always end up with same invalid scope error when I try to access the conversation API, 

    Any suggestion is appreciated

    thank you!

    0
  • Remi Saumet
    Zendesk Customer Advocate

    Hi Lev,

    Thank you for your post, hope you are doing well today!

    According to the requests / calls you want to make through the conversation API you will need more than the Chat scope and have to set the scope of the token to readwrite, and chat.

    Please refer to the section Authentication in Chat Conversations API for a better understanding.

    For instance, retrieve the Token with :

    https://www.zopim.com/oauth2/authorizations/new?response_type=token&client_id=CLIENT_ID&scope=read%20write%20chat&subdomain=SUBDOMAIN

    I would also encourage you to have a look at the following documentation : Getting started with the Chat Conversations API, that should point you in the right direction.

    Hope this helps!

    Have a great rest of your day.

    Best regards,

    0
  • Matt Schembri

    I've got an access token generated through "Implicit grant flow" detailed at https://developer.zendesk.com/documentation/live-chat/getting-started/auth/

    How can my Zendesk support app use this token?

    Is there a clear cut way to get chat data into a zendesk support app?

    0
  • John Espina

    Hi Matt,

    In regards to your concern, you can use OAuth 2 to authenticate all your application's API requests to Zendesk. OAuth provides a secure way for your application to access Zendesk data without having to store and use the passwords of Zendesk users, which is sensitive information.

    Please check this article: https://support.zendesk.com/hc/en-us/articles/203663836-Using-OAuth-authentication-with-your-application

    John Espina | Customer Advocate

    0

Please sign in to leave a comment.

Powered by Zendesk