Open trevoriancox opened 7 years ago
Thanks for pointing this out Trevor. I ll definitely take a look and make sure I improve the API.
@trevoriancox To get the ServerAuthCode on iOS, Where do we configure SignInOptions for GoogleSignIn?
Hi @trevoriancox, Thank you for raising this issue. I have updated the Android code for the plugin and it now follows the new Authentication mechanism which Google recommends.
Regarding the ServerAuthCode and IdToken APIs :
According to the Google documents on Sign-in integration here : https://developers.google.com/identity/sign-in/ios/backend-auth and https://developers.google.com/identity/sign-in/android/backend-auth, the recommendation is to use the IdToken for authentication on the backend server. Can you please let me know why IdToken will not work for your backend server authentication ?
@rhishikeshj You are right, thank you for pointing that out! I do only need id_token for my application. This also avoids asking the user for the unneeded "offline" permission.
Reopening this thread. What I need is to get a serverAuthCode from the OAuth2 flow. This means that not only will a token be returned but also a code that can be sent from the client to the backend server. This allows the server to convert that code into a token/refresh token for itself to use when contacting the Google servers without the user using the app. See this link for more details. https://developers.google.com/identity/sign-in/ios/offline-access Would be great for this to be part of the Xamarin.Auth library.
The access code returned by GetAuthToken can only be used in the client; it cannot be passed to a server. This means you can't use this library for Google Sign In if you need to be signed in on your server.
This is a feature of GoogleSignIn. I'm adding GetServerAuthCode() to the interface. I have it working for iOS.
For Android, there is an additional issue that GoogleAuthUtil, used in this library, seems to be deprecated and may not return the server auth code:
https://developers.google.com/identity/sign-in/android/migration-guide