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:
- I have
/auth/google
endpoint which triggers the google signin page - on success it redirects back to a callback url
/auth/google/callback
- 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
.
2
Answers
I was able to redirect back to app using
res.redirect("intent://app/login#Intent;scheme=myapp;package=com.myapp;end")
You can use following SDK for google authentication in react native which does’t required backend API or webView:
call config method in early stage like App.js
then you can use you SDK any where like this:
you can also visit SDK documentation :@react-native-google-signin/google-signin