Im using a client server application with react and node js and I want to set up an OAuth.
I’ve set a passport twitch into my api (node js) to authentificate poeple with twitch account. The Url and the callback are working and give me a user, then, in the callback function im sending a response in json. When I try the URL from my API, in a browser, I found the json that a I wanted to send.
The probleme come from my React application, I’ve make a service to call my API with axios but when Im trying to call the URL to authentificate with Passport, I got an error about the header Origin. I’ve try to add the headers into my API and client but Im still getting an error about this header.
Do you have an idea? The process client server with passport is possible?
The issue is that your page is making an GET request to that URL, which is not how OAuth works.
The correct way is to send the user to that URL, as the user has to be on the Twitch site to accept or deny connecting to your app. Once the user accepts or declines they will be redirected to your redirect URL.
I’ve already make the OAuth on my API side, and it’s working. When I’m calling my API in browser an authentification on Twitch ( with passportjs ) is lunch then the callback function from my API is call and a json is generate with the user OAuth authenticated.
My problem is to lunch the call API from the client side React JS .
I tried to get this URL with axios :
The authentification on twitch is lunch but I got an error in the callback function. Im just trying to acces to the json rended by my api but the error in the console in a picture above is about Headers from twitch. There is an URL in the error message and when Im clicking on it, Im getting the Json from my API.