Hello there @deepdev and welcome to the community!
You can use the SDK to make your API calls if needed.
Regarding OAuth, your steps look good to me. You can read more about it here and check out an example here 😀
As mentioned, you can use the SDK directly if you do not want to use OAuth.
I hope that helps!
Cheers,
Matias
Hi, I’m proceeding with OAuth testing. Not sure what the problem is but I get a response from the token service with the error:
(log) ControllerMonday: sending request to get token with - {"client_id":"NNNNN","client_secret":"NNNNN","redirect_uri":"MY_REDIRECT_URI","code":"NNNN"}
(log) ControllerMonday: token response, getting access token
(log) ControllerMonday: token response, body is - {"error":"invalid_request","error_description":"Missing client_id param"}
I’m receiving the redirect callback with the access code just fine. But, then I set all the values including “client_id” and calling https://auth.monday.com/oauth2/token and I get the response that “client_id” is missing…
I had a similar error when I first started testing OAuth for Monday apps and it was because my app settings had changed and I had to redeploy the app so that my OAuth settings had taken effect. But, my app hasn’t changed and I’ve verified the client_id and client_secret as well as the code being sent are correct.
But, at this point, I’m at a loss. I’m passing the client_id and what I thought was odd was that in the sample code that you referenced, they used this for their POST configuration:
GITHUB EXAMPLE CODE
var authRequest = {
url: 'THE_TOKEN_URI',
form: {
redirect_uri: redirect_uri + "/oauth/callback",
client_id: client_id,
client_secret: client_secret,
code: code,
},
};
They’re using “form” instead of “body” to POST the data to the token service. I tried both with “body” and with “form” and get the same response. Here’s my code…
// Call monday enpoint
var config = {
method: 'POST',
body: JSON.stringify({
client_id: this.Env.MONDAY_CLIENT_ID,
client_secret: this.Env.MONDAY_CLIENT_SECRET,
redirect_uri: ControllerMonday.OAUTH_REDIRECT_URI,
code: code
})
};
console.log("ControllerMonday: sending request to get token with - "+ config.body);
var req = new Request(ControllerMonday.OAUTH_TOKEN_URI);
var res = await fetch(req, config);
Any ideas? Thanks
I see thanks! Yep, I think I understand now how an IFRAME can use the SDK and allow my app to auth via the SDK (sessionToken being present/available) vs having to implement OAuth and do the user/token mapping in my own backend. I got the OAuth support written this weekend so I’m going to test it and maybe just run with that for now.
But, as I get more experience and understanding of the Monday platform, I suspect just using the SDK and the JWT/sessionToken can work just as well and possibly a little easier. I guess it never hurts to implement both just so I truly understand all the pros/cons and exactly how Monday works.
Thanks again!
There are only three circumstances I know of that you need an OAuth token for:
- You have long running tasks that take more than the 5 minutes of the JWT/shortLivedToken.
- You want to offload front end tasks to a backend (maybe some sort of queue)
- You wish to run background tasks on a backend - such as cron jobs to get account size and subscription data.
There is a fourth, which is you have webhooks which you then execute some sort of saved configuration for, rather than using actual integration recipes. This is an anti-pattern. Though it comes up because there is no way to create an integration recipe from a front end app - only webhooks.