Search code examples
androidreact-nativeexpresspassport.jsgoogle-signin

how to implement google sign in react-native using expressjs and passportjs


I have my web apps which use google authentication configured via passportjs in my express backend. Now i want to create react-native apps for the same. I am trying to implement google signin using same apis, but it is not working.

On my backend:

  1. I have /auth/google endpoint which triggers the google signin page
  2. on success it redirects back to a callback url /auth/google/callback
  3. then it redirects back to the frontend(client) url.

Now in case of react-native apps, i open the /auth/google in a webview, which triggers the google signin page, on success it gets to callback url and then while redirecting back to frontend(client), i do res.redirect(myapp://app/login), but it shows Cannot GET /auth/google/myapp:app//login.


Solution

  • I was able to redirect back to app using res.redirect("intent://app/login#Intent;scheme=myapp;package=com.myapp;end")