After login, browser failed to load the redirected page:
http://localhost:5000/callback?code=###,
{"message":"Not Found","error":{"status":404}}
And the server console error is as follows:
Error at C:\codes\predix-seed\node_modules\passport-oauth\lib\passport-oauth\strategies\oauth2.js:125:38 at C:\codes\predix-seed\node_modules\oauth\lib\oauth2.js:177:18 at ClientRequest. (C:\codes\predix-seed\node_modules\oauth\lib\oauth2.js:148:5) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at TLSSocket.socketErrorListener (_http_client.js:309:9) at emitOne (events.js:96:13) at TLSSocket.emit (events.js:188:7) at emitErrorNT (net.js:1281:8) at _combinedTickCallback (internal/process/next_tick.js:74:11)
Answer by Steven · Oct 25, 2017 at 09:52 AM
Hi @y fan.yang@constellation.com
It seems that your callback endpoint is not working or has exceptions. Could you attach your app.js file?
One more thing is make sure your UAA client has authorization_code in Authorized Grant Types
Answer by Jackie Tran · Oct 24, 2017 at 02:56 PM
Did you all setup redirect url in uaa dashboard. Sometime if you missed setup redirect url, it's also caused callback error.
Regards, Jackie
I believe what you want to add as a redirect URI is: http://localhost:5000/callback if they plan on using it like the topic creator indicated.
Answer by Timothy Selaty · Dec 09, 2016 at 08:27 AM
In order for the Passport Predix OAuth
to successfully handle the code provided from the authorization_code
login authentication process inside of Node.JS, a callback URL has to be setup in Node.JS.
In the case of the Predix Seed repository, they should have already defined this for you on the following lines:
https://github.com/PredixDev/predix-seed/blob/develop/server/app.js#L107
//callback route redirects to secure route after login
app.get('/callback', passport.authenticate('predix', {
failureRedirect: '/'
}), function(req, res) {
console.log('Redirecting to secure route...');
res.redirect('/');
});
If your localConfig.json
file checks out, which you can find exampled here, https://github.com/PredixDev/predix-seed/blob/develop/server/localConfig.json then the Predix OAuth library should be able to handle the ?code=
automatically. I'll download the repo and give it a shot in just a moment.
P.S. I know the Predix OAuth developers just changed the repo literally two days ago, so it might be related to that.
Answer by sebastian.dunkel@ge.com · Apr 26, 2017 at 09:20 AM
I do have exactly the same issue. Unfortunately, I can not figure out, what I have to do to 'setup a callback URL in NodeJS'. Can anyone guide me briefly or has another solution?