-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Clarification on OAuth Flow #1118
Comments
Hey @mikeover , it's been noted in several other issues that this gem doesn't play nice with Rails 5 API and Omniauth....you probably need regular ol' Rails 5. I'm thinking that the view that has JavaScript to close the oauth window and go back to your original window isn't loading though. Please search the issue queue for more info |
I've pretty much read every open and closed issue twice. If you have an idea of why it doesn't work with Rails 5 API and Omniauth, I'd be happy to look into it and try to submit a PR. Just need some initial suggestions on where to start. |
Have you tried looking at the view that omniauth uses for the, "login window" that isn't closing? |
That's not the issue I'm most concerned with. What I need is for the token that gets created for the new user to make it back to the frontend React app. It just goes one direction now from React -> backend -> twitter.com -> backend. It needs to go full circle back to React with the new token. |
Yup, and that backend to frontend connection at the end usually happens on that page. Twitter.com returns to your backend, which returns this view that I'm talking about which has Javascript to close the window and send the token back to your application. Something like this: |
Is that different than just doing a redirect from within |
I'm just trying to explain how that last step is done. I'd recommend doing a bit more research on how the window is closed. |
That's fine, but again I'm less concerned with closing the window (I can just do it in the same window if it's causing a problem) as I am with figuring out how the React front end will get access to the token for the user. |
Yup, and what I'm trying to say is, I'm pretty sure around the time the window is closed, other JavaScript code is sending that token back. Just a theory though. Good luck! |
@zachfeldman One more question if you don't mind. I'm overriding In Something like within
|
Hey, that sounds like it might work! You should try it |
@mikeover Sorry to ping you from such an old issue. I've tried your snippet, and it seems to work in my environment, too. |
@alea12 I'm no longer working on this project and haven't been for a few years, but I believe this worked for me to the best of my recollection. |
@mikeover Thank you for your remarks! |
I'm using this with a Rails 5 API and a separate React/Redux app using https://github.com/kylecorbelli/redux-token-auth.
I have it mounted at
/api/v1
:Here's what I have happening right now:
/api/v1/auth/twitter
(which is handled in the backend Rails app)/api/v1/auth/twitter/callback
users
table/api/v1/auth/twitter/callback
What I need is for the user to get back to the React frontend app and be authenticated with the token for the new user that was just created.
What am I doing wrong? Am I wrong to initially redirect to the backend API which handles the oauth flow? I've seen some comments about doing this in a new window but I don't see any documentation on how to do it besides using the jQuery library (which I don't want to do).
Any help appreciated!
The text was updated successfully, but these errors were encountered: