Just released the Google Client Plugin, it makes the process of authenticating a user across Xamarin Forms, Xamarin.Android and Xamarin.iOS with Google Sign In easier.
Set Up
The setup process for the plugin is pretty simple and it’s well documented on the Google Client Plugin GitHub page. you can complete the Setup process following these steps:
- Install the nugget package into your PCL project and Client projects.
- Create your Google Firebase Console Platform application.
- Follow the Android and iOS guides
Use It
You just have to use GoogleClient.Current
Login
Here is an example of how to launch the login to the Google Client:
CrossGoogleClient.Current.LoginAsync();
This method returns a Google User which contains the basic profile of the user that was authenticated, with the following structure:
Logout
Here is an example of how to log out of the Google Client:
CrossGoogleClient.Current.Logout();
Available Properties
- ActiveToken (Signed In user token)
Events
All async methods also trigger events:
Login event:
Official Google Sign In SDK Documentation:
https://developers.google.com/identity/
Full documentation of the project:
https://github.com/CrossGeeks/GoogleClientPlugin
Xamarin Forms sample project:
https://github.com/CrossGeeks/GoogleClientPlugin/tree/master/GoogleClient/GoogleClientSample
Made with ❤ by Pujols
Google sign works fine in android. But on ios, getting 7 native linking errors:
Native linking error: clang: error: no such file or directory: ‘/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseNanoPB’
Native linking error: clang: error: no such file or directory: ‘/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/GoogleSignIn’
and 5 more related with firebase
Hey Vipin,
This is a known issue in iOS you can learn about the solution in this thread https://github.com/CrossGeeks/GoogleClientPlugin/issues/21, or find other alternative solutions on forums.
installed missing ‘xamarin ios googlesign’ and ‘xamarin android firebase’ nuget packages removed errors…working now..
Alright! Great job, I’m glad you got it working☺️🙌
HI, thanks for the amazing plugin, but i keep getting the same error on iOS while on android i fully functional.
The error i get is when i launch the app on iOS when calling the GoogleClientManager.Initialize(); it trows an error saying “Value cannot be null. Parameter name: path”
Hi Pedro!
I’m glad you found the plugin helpful, it’s my pleasure. this issue is probably because you are missing the GoogleServices-Info.plist file on your iOS project or the Build Action of the file is not BundledResource please verify.
Thanks!
Android:
_googleClientManager = CrossGoogleClient.Current;
Unhandled Exception:
Java.Lang.ClassNotFoundException: com.google.android.gms.auth.api.Auth
Any ideas?
ps. does post comment even work? akismet suspected me as spam wtf
Hey Deathly!
I’m glad you are looking forward to use the plugin, and yes haha Akismet can do that sometimes sorry, please verify that all the dependencies for the plugin were installed correctly when you installed the NuGet, you can check the dependencies on Nugget Gallery. https://www.nuget.org/packages/Plugin.GoogleClient
Thanks for reply. I have already managed to fix it. I was just blind.
FIX for others blind persons like me 😀 :
Install dependencies:
Xamarin.GooglePlayServices.Auth (>= 60.1142.1)
Xamarin.Google.iOS.SignIn (>= 4.1.1)
I’m glad you got it working! Great job🥳🎊
Hi, great plugin for authentication, but how can I get the authentication token and refresh token to use with google apis? I understand that the CrossGoogleClient.Current.ActiveToken is supposed to have the authentication token, but for some reason mine does not. After authentication I check and it still seems to be null.
Hey Joe! to get the authentication token you must initialize the plugin with your google developer client ID, we have a section in the GitHub Getting Started guide were you can see how to enable these tokens.
Hi, thanks for amazing plugin but after update to latest version I’m getting error in iOS Failed to resolve “Google.SignIn.ISignInUIDelegate” reference from “Google.SignIn, version=1.0.0.0, Cultuer=neutral, PublicKeyToken=null” MT2002.
Any Idea what I’m missing here?
Hello Surendra, I believe someone has already reported this issue on the github page of the plugin. There seem to be some issues with the latest version of iOS we are waiting on apple to see if it resolves with further updates if not we will take some time to check it out further. Thanks for the kind words we are glad you are able to make use of the plugin 🙂