OAuth, setting parameters to request data from external app.

7 댓글

  • Eric Nelson
    Zendesk Developer Advocacy
    Hey Samer,

    The oAuth parameter is a controlled type that you need to use if you want oauth to function correctly. We cover this in our documentation here. You shouldn't be inputting the token in advance, the application will create and store this. 
     
    Lastly our "get" example is just showing how to call an endpoint that uses oauth. The authorization flow uses a POST to handle the auth. You can read about that here

    Thanks!
    0
  • Samer Kokeh

    Thank you for your post, I hope you keep following my post.

    However, When i read your document here  I think there is some mistake in your code if you check it.

    const client = ZAFClient.init()const settings = {  url: 'https://www.example.com/api/user',  headers: {authorization": "OAuth {{setting.access_token}}"},  secure: true,  type: 'GET',  dataType: 'json',  contentType: 'application/json'}

    You can see headers parameters, it's not correct, I think Authorization it should be capital letter.
    Can you tell me exactly please, what are the parameters i should use in my manifest?
    and how to use my call in my main.js?

    0
  • Samer Kokeh

    FYI, i used in manifest.json

    "parameters": [
            {
                "name": "token",
                "type": "oauth"
            }
    And in my main.js
    var settings = {
            url: crmurl,
            headers: {"authorization": "OAuth {{setting.token}}"},
            secure: true,
            type: 'GET',
            dataType: 'json'
            };

    then when I reinstall my app on zendesk, it give me a sign that it's authorized. as bellow 
    But whenever i try to run my app I got an error.
     
    0
  • Tipene Hughes
    Zendesk Developer Advocacy
    Hi Samer,
     
    It appears that the code sample in the link you provided is slightly incorrect, unfortunately. As you mentioned, the parameter "authorization" should be capitalized as well as double quoted, but also you'll want to replace "Oauth" with "Bearer". Here's an example of how that should look:
     
    const settings = {
    url: 'https://www.example.com/api/user',
    headers: {"Authorization": "Bearer {{setting.access_token}}"},
    secure: true,
    type: 'GET',
    dataType: 'json',
    contentType: 'application/json'
    }
     
    I'll be sure to have our documentation team updated the provided sample. If you have any more issues, feel free to reach out!
     
    Tipene
    0
  • samer

    Hi Tipene,

    Thank you for information, but I still have a problem. Please if you want to open a ticket let it's ok.
    FYI, I already request a ticket and still no body answer me.
    However, I updated my Code as you mentioned it succeeded and keep working for 1hour or less and after 1 hour, when it's need to refresh the token, it's stop getting the data and an error raised as bellow:

    1. responseText"Proxy error: {:code=>\"UnprocessableEntity\", :status=>\"422\", :title=>\"Unprocessable Entity\", :message=>\"Failed to get installation and oauth information for app.\"}"
    2. status422
    0
  • samer

    FYI, whenever I Open my App Settings. I can see that it's Authenticated 

    and when I click on Reauthorise with D365, i don't have any error and after i click Update, the application run again without any trouble for only 1 hour.

    Please Advice or open a ticket for support.

    Kind Regards,
    Samer

    0
  • Eric Nelson
    Zendesk Developer Advocacy
    Hey Samer,
     
    I'll be assisting with you through the ticket that you opened up to help resolve this issue. Look forward to working with you via that!
     
    Thanks,
    0

댓글을 남기려면 로그인하세요.

Zendesk 제공