Recent searches


No recent searches

OAuth, setting parameters to request data from external app.



Posted Apr 28, 2022

Hi,

I am trying to call an external app API.
I found on your documentation two types of setting on manifest.json.

 "parameters": [
        {
          "name": "token",
          "type": "oauth"  or "text"
        }
what is the deference between text and oauth, when you use text? oauth?
 
secondly, when I configure this parameters, is it necessary to input this token, which i may create it on Postman? If i didn't pas this parameter would the application create token by using my settings "Client_id, client_secret etc"?

Last question, according to what i read, I understood about OAuth flow that an Authorization request should be created with Post request and passing ClientID and Client secret... should be post to grant the token, I found on your documentation that you send the request of Get, you are not requesting the token before you get the data, What if that saved token which you pass it in header is expired. please clarify.
Thank you,
Samer 

0

8

8 comments

image avatar

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


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


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


image avatar

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


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


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


image avatar

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


Was this resolved and how, since I'm facing exact same issue after 1 hour...

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post