Closed dadja closed 6 months ago
Hey @dadja, using Google's native sign SDK (com.google.android.gms:play-services-auth
) dependency in a non-web TurboFragment
is the way to go. Google does not permit authentication in an app WebView
, due to security concerns.
When you authenticate the Google account against your server, you'll want your server API to return WebView
authentication cookies to use. You'll then need to use the CookieManager
to set the cookies in the WebView
:
https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String)
This will allow the user to have proper authentication for your web application when navigating in TurboWebFragment
instances.
Thanks for the quick reply and for this helpful insights ! @jayohms my next question is as on native we need to build the Google Sign on a fresh activity , I will need to call a TurboActivty that has a NavHostFragment where I can define then the cookie auth solution you proposed right ? Or is it preferable to make the activity itself a turbo activity and work on switch the Ui from the Google Sign In button to a NavHostFragment(which from my thinking makes things harder) what do you think sir. ?
@dadja Here is a sample application of Google Sign In With Turbo Android. https://github.com/kzkn/turbo-native-google-signin-demo
See also: https://developers.google.com/identity/sign-in/android/start
thanks a lot @kzkn for sharing this !
FYI: I've updated the demo app to use the cookies to pass the id token
.
Hello @jayohms ,thansk for this wodnderful library you wrote; i have a question i am currently lost on how to implement a Google Sign In my turbo app. We started by buildsibng for the web and it wortks fine but on androdi when we click on the botom it open an new navigatoer and prtopose to us logins to choose from and then continue on that same page instead of getting back tio the app like other apps does it . we decide because of that to go with a native actiuty that handle the google sign in and send request to our server . But here i am also lost on how to start a new activity with the right data in a session and more ; do you have any insight that cxan help me move foreward with this please thanks