-
Notifications
You must be signed in to change notification settings - Fork 84
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
Sending the token to a separate frontend application from Phoenix api-only app #37
Comments
Are you using the code or the token flow from google? Also can you please show your auth controller (where you have the Ueberauth plug) and your ueberauth config / routes (no secrets please!) |
This is the repo (https://github.com/ghoshnirmalya/social_app_api) in which I'm using this library. Link to my auth_controller: https://github.com/ghoshnirmalya/social_app_api/blob/master/web/controllers/auth_controller.ex. |
This case statement isn't doing anything: https://github.com/ghoshnirmalya/social_app_api/blob/master/web/controllers/auth_controller.ex#L34 (remember... immutable data!) I don't think that you're actually getting a signed in connnection (you generate the token but the conn is lost) Can you explain how you're using the 'fetch' api here? The usual flow for the code flow would be:
If you're wanting to oauth to an SPA you need to use the token auth (client side oauth). Unfortunately Ueberauth google doesn't yet support this but this PR #35 will bring it in. I haven't had a chance to properly review it yet but will do soon. |
I can confirm that I'm getting a signed in connection since if I pass the token sent after signing in, all the other routes work. Whereas, if I don't send the token, the routes doesn't work. Also, my major problem while handling authentication on the frontend is I don't know which api to ping for the authentication to work. When I ping it from my frontend application, which is running on localhost:3000, I get something like the following: N.B. |
If I use a client-side oauth like react-google-login, it will send me a token after authenticating with Google but I'm unsure how I can validate that token with ueberauth_google. |
Currently, this is the way I'm handling logging a user in:
I'm unsure if this is the correct way to do this. |
Hey I'm having this very issue. Has a better solution been found then two separate auth steps? |
Exactly the same problem - but with an Ember app (will also need it to work for a React app). I have a PoC showing Ueberauth can authenticate against Google, Microsoft, Okta, etc with an API based Phoenix backend but the callback stage has to ultimately result in a redirect back to the separately hosted front-end. [in fact - I based it off the work from @ghoshnirmalya to get the Phoenix part working] |
Hey so there a better solution for this? or could someone explain the second step? |
How are we supposed to send the token to the frontend application since the frontend application will have to open a new window for Google authentication to work properly. So, when we send the token to the frontend from the new window, only the token will be rendered in the window as json.
For example, in my backend application, I ping
localhost:4000/api/v1/auth/google
to get the token. But when I ping it from my frontend application, which is running onlocalhost:3000
, I get something like the following:I'm guessing this happens because I'm not requesting it from a new window! But, if I request it from a new window, how will the token be sent to the parent window?
The text was updated successfully, but these errors were encountered: