Hey FusionAuth Community,
in the last few days I installed a docker image of fusionauth on my vserver, set everything up and made a new application.
After that I used this tutorial:
https://fusionauth.io/blog/2020/03/10/securely-implement-oauth-in-react
to build a React-Express App. I made a few changes like serving the react app in a static way over the public folder, so it can run on my vServer without problems.
Everything worked just fine and you can visit the app on http://login.ruffyg.de/
But when I try to login with the right credentials my page redirects me to
http://login.ruffyg.de/oauth-callback?code=8LS2k9VlXp43j-C7NGXKy9n_X3a9GA0jSIeKrBDUxeU&locale=de_DE&userState=Authenticated (<- I changed a few letters for security reasons)
Normally it should redirect me to my react app, right? My oauth-callback.js looks like this...
const express = require('express');
const router = express.Router();
const request = require('request');
const config = require('../../config');
router.get('/', (req, res) => {
request(
// POST request to /token endpoint
{
method: 'POST',
uri: `http://login.ruffyg.de:${config.fusionAuthPort}/oauth2/token`,
form: {
'client_id': config.clientID,
'client_secret': config.clientSecret,
'code': req.query.code,
'code_verifier': req.session.verifier,
'grant_type': 'authorization_code',
'redirect_uri': config.redirectURI
}
},
// callback
(error, response, body) => {
// save token to session
req.session.token = JSON.parse(body).access_token;
// redirect to the React app
res.redirect(`http://login.ruffyg.de:${config.clientPort}`);
}
);
});
module.exports = router;