-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
Authentication Client: how to implement Google and Facebook Logins (oauth)? #2186
Comments
How to set up Facebook login for a browser application is described in this Cookbook entry. How to use oAuth with e.g. React Native is described in the docs for flow #2. You first have to obtain the oAuth access token first through the Facebook or Google mobile SDKs. |
@daffl Thanks for your prompt response. I previously read the cookbook entry you shared, and it only covers implementation in the backend. My question is focused on the the authentication-client module. How do you connect it to the backend implemented in the cookbook entry in order to achieve flow #1? I will explore the docs you shared for flow #2. |
You call
|
@daffl For some reason, app.reAuthenticate() and app.authenticate() will not automatically pickup the token passed back in the URL by the server. I may have to do a manual implementation. Also, what is the difference between app.authenticate() and app.reAuthenticate() when using jwt with oauth? |
That difference is also explained in the documentation I linked. The token should picked up as soon as |
@daffl This seems to be similar to #2031 and #2116. In all three, things get weird with the redirects if the In my particular case the Feathers backend is located behind I've read through all the referenced documentation, but I can't figure out how to handle this scenario. |
This is a bug tracked in #2031 |
#2031 has been fixed in |
Steps to reproduce
I have gone through the official documentation for authentication-client, and also read multiple articles. There exists content for local strategy, but there is none for oauth.
Some context: I am trying to implement authentication for both a React web-based frontend and a React-native app calling the same Feathers backend api. Web-based frontend and backend api are running on different servers/domains.
The client implementation for the local strategy appears to be easy because the authentication-client is simply making a call to the backend and receives a JWT upon successful login.
It's a bit complicated for oauth, and I am yet to see a clear example. At the moment, I just redirect from the frontend to backend/oauth/google. However, according to the official docs, I have to put backend/oauth/google/callback in the oauth settings on Google. This means that when the authentication is done, the app redirects to the backend and not to the frontend, and this is not the desired behavior. Also, calling fc.authenticate() in the frontend results in an error if accessToken is not yet available.
Expected behavior
I need a way to implement authentication in the frontend client, such that when a user clicks the login button, they are redirected to the Google (or any other Oauth) login page, and upon successful authentication, they are redirected back to the frontend, with the accessToken already saved in localStorage (or AsyncStorage), and the corresponding entry created in the users table for new users. Feel free to point me to any publicly available resource or share sample code here.
Also, for React-Native, how do I get feathers authentication client to use the native login popup instead of redirecting to the browser-based Google login page? This will improve the UX on Android devices.
System configuration
I am using feathers v4
The text was updated successfully, but these errors were encountered: