OAuth, setting parameters to request data from external app.
Hi,
I am trying to call an external app API.
I found on your documentation two types of setting on manifest.json.
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.
Samer
-
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!
-
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? -
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 -
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
-
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:- responseText: "Proxy error: {:code=>\"UnprocessableEntity\", :status=>\"422\", :title=>\"Unprocessable Entity\", :message=>\"Failed to get installation and oauth information for app.\"}"
- status: 422
-
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 -
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,
Please sign in to leave a comment.
7 Comments