-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: State is not matching #8
Comments
Think I figure this out, was generating a state token, then calling |
@nodesocket Can you be more specific on where you had the issue? I'm also have the same error and would like to know if it's related. Thanks! |
I thought we fixed it, but seeing it again.
Any official word from oauth.io? It seems intermittent. It will happen, then we wait a few minutes and the error magically goes away. Looking at the coffee script source
|
@nodesocket So I'm noticing that after the You can see a working example at the fork I made for the sdk-node-tutorial: https://github.com/brutalhonesty/sdk-node-tutorial I'm able to get the client to server-side workflow working, however, I cannot test my endpoint because I need to have a code to make with in the session right now. Going to see if I can load the req.session value with a static code and that way the if statement is true. |
We are using server-side only. Here is basically all the node.js code paths we have. Do you spot anything wrong? |
@nodesocket I'm a bit confused with the My client-server workflow is here: |
@nodesocket @brutalhonesty Did either of you get around this? I'm currently at the state of #12, but when I add in |
@brutalhonesty @nodesocket, below is an rfc: Potential Cause 1Does the client need to pass the token to the server, is that what is causing this? If so, how do you instruct oauth to look for this token? Potential Cause 2Does Potential Cause 3Does it have something to do with csrf? I am not using csrf so it makes sense that { public_key: 'LONG_STRING_FOR_APP_ID',
secret_key: 'LONG_STRING_FOR_APP_SECRET',
csrf_tokens: [],
oauthd_url: 'https://oauth.io',
oauthd_base: '/auth' } |
When I dug into this issue a few months ago, I think it was somewhat related to cause 3 but I need to dig into it again soon for an existing project. Until then, I won't be able to help much with a possible solution. |
@brutalhonesty I think you are right. I'm looking at what |
@william26 I could use your help on this. A POST to Here's the code: app.get('/oauth/token', function(req, res) {
var token = oauth.generateStateToken(req.session);
return res.send(token);
});
app.post("/oauth/signin", function(req, res) {
debugger;
var code = req.body.data;
oauth.auth("google", req.session, {
code: code
}).then(function(request_object) {
debugger;
return res.send(200, "The user is authenticated");
}).fail(function(e) {
debugger;
console.log(e);
return res.send(400, "Code is incorrect");
});
return res.redirect(req.session.returnTo || '/');
}); |
I had the same issue and figured out that I was not using the express-session middleware in node. Using this and node-uuid I was able to pass in the session to the generateStateToken() call. The following are just code snippets and are not intended to run as is. Where you do your requires var session = require('express-session')
var uuid = require('node-uuid'); Where you set up your middleware app.use(session({
genid: function(req) {
return uuid.v4();
},
secret: 'some secret',
resave: false,
saveUninitialized: true
})); Where you request the initial token from the client. I do this on client page load. app.get('/email/twitter/oauth/token', function(req, res){
var token = OAuth.generateStateToken(req.session);
console.log('token', token);
console.log('OAuthgetCsrfTokens', OAuth.getCsrfTokens(req.session));
console.log('req.session.id', req.session.id);
res.status(200).send(token);
}); Now when the post to log in is received I call this function which now works function twitterLogin(req, res, code) {
console.log('twitterLogin', code);
OAuth.auth('google', req.session, {
code: code
})
.then(function (r) {
// Do something with r.access_token,
// or r.get|post|put|delete|patch|me()
// Or just send a success message :
console.log('twitterLogin success response', r);
res.status(200).send(r.access_token);
})
.fail(function (e) {
// Handle an error
console.log(e);
res.status(500).send('An error occured');
});
} I hope this helps someone. It was a bit of a struggle to figure out. Brent |
👍 |
Seeing intermittent errors calling
OAuth.auth()
, where it falls into thefail()
block. Theerr
is simply:What does that mean? We are using redis to store sessions by the way.
Here is the full block of code we are using:
The text was updated successfully, but these errors were encountered: