mondora / asteroid

An alternative client for a Meteor backend
MIT License
734 stars 101 forks source link

loginWithGoogle redirect_uri_mismatch #35

Closed hexsprite closed 9 years ago

hexsprite commented 9 years ago

I'm getting this error from Meteor on the server side

W20141127-09:50:17.280(-8) (oauth_server.js:398) Error in OAuth Server: Failed to complete OAuth handshake with Google. failed [400] {   "error" : "redirect_uri_mismatch" }

I checked the login url that is being generated by Asteroid:

https://accounts.google.com/AccountChooser?service=lso&continue=https%3A%2F%2Faccounts.google.com%2Fo%2Foauth2%2Fauth%3Fscope%3Dopenid%2Bemail%26response_type%3Dcode%26redirect_uri%3Dhttp%3A%2F%2Flocalhost%3A3000%2F_oauth%2Fgoogle%26state%3DeyJsb2dpblN0eWxlIjoicG9wdXAiLCJjcmVkZW50aWFsVG9rZW4iOiJlODk0N2M1MzVkYTZjMzg4NGUzM2MxYjVjZjQ5M2NhOCIsImlzQ29yZG92YSI6ZmFsc2V9%26client_id%3D60750537449-d2469pvur5lkfh4fs6cgo7q0100hk60g.apps.googleusercontent.com%26hl%3Den%26from_login%3D1%26as%3D-775f8062e42146ac&btmpl=authsub&hl=en

Compared to what is being generated by Meteor

https://accounts.google.com/AccountChooser?service=lso&continue=https%3A%2F%2Faccounts.google.com%2Fo%2Foauth2%2Fauth%3Fzt%3DChRQNW1LRng5NktlMFg0eHNhVUFQdRIfY3NvMDJ2NG1oOWtib2lJQmVPNlAybV9DR2JMa2t3SQ%25E2%2588%2599APsBz4gAAAAAVHdlnpuxD-W9_tPpKB5z3StCb_h4pCLI%26from_login%3D1%26hl%3Den%26as%3D-59273d9af2e8a0a5&btmpl=authsub&hl=en

I checked and the redirect_uri that is in the loginUrl generated by Asteroid is in my Google API configuration. (http://localhost:3000/_oauth/google)

pscanf commented 9 years ago

Mmh, I think I saw that error a couple of times too. Iirc it was because google takes a bit of time to update the redirect_url, but it may not be the same issue. If I find time I'll take a look at it later tonight (can't promise anything though :-( , too many things to do, too little time. Alas, life... :-D )

hexsprite commented 9 years ago

@pscanf fair enough. I made some progress by adding ?close to the redirect URL. Now it gets past that point without the server side error. But the login window remains open and I don't actually get logged in.

hexsprite commented 9 years ago

Aha. Looks like running it from a file:// URL is not ok in terms of origin checking.

Uncaught SecurityError: Blocked a frame with origin "http://localhost:3000" from accessing a frame with origin "null".  The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "file". Protocols must match.
pscanf commented 9 years ago

Did you manage to fix it at the end? May have been the same issue of #69. Closing for cleanup, reopen if necessary.