I’m building a new React app (which needs to call my .NET API) with the Monday.com developer platform. Ultimately, I want my API to interact with Monday.com APIs impersonating the user.
The first thing I’m trying right now is to authenticate the user to my app using OAuth as described in OAuth and Permissions (monday.com) to get the access token.
Then I can provide the access token to backend API calls.
Currently, I’m only have the app running locally.
I do get an authentication code when calling the authorization endpoint.
The problem arises when I call the token endpoint with the authentication code:
First, I call the authorize endpoint which is showing the Monday authorization page with the Authorize button. When I click that button, I get an authorization code back on my callback URL.
Then, I try to call the token endpoint with the authorization code to get the access token. I overhauled the code a bit, but I’m still stuck with the same error message.
Access to fetch at ‘https://auth.monday.com/oauth2/token’ from origin ‘https://23ee4be0f152.apps-tunnel.monday.com’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.
The tunnel is forwarding requests to my app running locally in Visual Studio Code.
Or can I not test it in this way with the tunnel? I’d like to test before I publish.
David’s answer was leading me in the right direction.
I created a new React application with Next.js and the Nextauth library to do the OAuth authentication. Now I have a working login process.