OAuth, how to configure it.

Answered

6 Comments

  • Greg Katechis
    Zendesk Developer Advocacy

    Hi Samer! I'll go through your questions one by one, but please let me know if I misunderstood the question in any of them!

    1. As I understood, I may configure oauth details in manifest file after I deploy my App, is it correct? 

    The details that you include in your manifest have to be present when you deploy the app, unless you are using placeholder values. 

    2. I'm not sure that I understand the question here...could you clarify this one for me?

    3. Yes, you can read about that here!

    0
  • Samer Kokeh

    Hi Greg,
    Thank you for your post. However, to clarify my question 2;
    I filled manifist.json with values of client_id, client_secret, authorize_uri and access_token_uri.
    And when i tested my code i always receive 401 error. but when i used the same values on Postman it's ok and it's work very well. So that, I copied my token from postman and use it in my zendesk app to complete my application until I solve this problem. or until I upload my app.
    That's why I thought it's only read the setting of OAuth in manifist.json after deployment.
    so now my code to call api is like this:

    var settings = { 
            url: `https://mycompany.crm4.dynamics.com/api/data/v9.0/accounts?$filter=contains(accountnumber,'${externalId}')`,
            headers: { "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGci......},
            type: 'GET',
            dataType: 'json'
        };

    I don't think it's correct to keep using access token from Postman even before uploading my application. 

    Thank you in advance...
    Kind Regards,
    Samer

    0
  • Greg Katechis
    Zendesk Developer Advocacy
    Thanks for clarifying that. If you're receiving a 401, it means that there is something going wrong with the auth flow. Could you print the token that's generated in your auth flow to the console when running your app to see if the token is being generated properly?
    0
  • Samer Kokeh

    Hi,

    Please check the attachments of manifest.json, main.js and the error appears on chrome console.

     

    0
  • Samer Kokeh

    Here is also a screenshot of my console when i run the app.

    0
  • Samer Kokeh

    FYI, I tried the same configuration on Postman and it's work very well, the only thing is missed when I compare my postman configurations is Scope, Scope value in postman is 

     
    And i am not sure if the setting is correct because as you can see in my code i tried to write the value of access_token parameter which i fill it when i run "Zat server" but it's appear as is 
     console.log("Token: {{setting.token}}" ); ==Consol output=> "Token: {{setting.token}}" .
    Regards, 
    Samer
    0

Please sign in to leave a comment.

Powered by Zendesk