Skip to content
Branch: master
Find file Copy path
Find file Copy path
2 contributors

Users who have contributed to this file

@Pujolsluis @stealthcold
168 lines (124 sloc) 5.47 KB

Getting Started

If developing an application that supports iOS and Android, make sure you installed the NuGet package into your PCL project and Client projects.



Here is an example on how to launch the login to the Google Client:


This method returns a Google User which contains the basic profile of the user that was authenticated, with the following structure:

    public class GoogleUser
	public string Id { get; set; }
        public string Name { get; set; }
        public string GivenName { get; set; }
        public string FamilyName { get; set; }
        public string Email { get; set; }
        public Uri Picture { get; set; }


Here is an example on how to logout of the Google Client:


Available Properties

  • ActiveToken (Signed In user token)


All async methods also trigger events:

Login event:

  CrossGoogleClient.Current.OnLogin += (s,a)=> 
     switch (a.Status)
         case GoogleActionStatus.Completed:
          //Logged in succesfully


Types of exceptions the user can handle from the Google Client plugin.

    // Indicates Google Client Plugin was not initialized correctly on the platform.

    // Indicates Google Sign In could not complete it's process correctly.

    // Indicates an unknown error has occured.

    // Indicates a problem reading or writing to the application keychain.

    /* Indicates no appropriate applications are installed on the user's device which can handle
    sign-in. This code will only ever be returned if using webview and switching to browser have
    both been disabled. */

    /* Indicates there are no auth tokens in the keychain. This error code will be returned by
    signInSilently if the user has never signed in before with the given scopes, or if they have
    since signed out. */

    // Indicates the user canceled the sign in request.

    // Indicates the client attempted to call a method from an API that failed to connect.

    // Indicates The client attempted to connect to the service with an invalid account name specified.

    // Indicates a network error occurred. Retrying should resolve the problem.

    // Indicates an internal error occurred.

    // Indicates the client attempted to connect to the service but the user is not signed in.

    // Indicates the sign in attempt didn't succeed with the current account.

Enabling Server Auth Code or RequestIdToken Programmatically (Optional)

If you have a more complex development flow, that integrates CI in which it's better to just set your Server Client ID and RequestIdToken programmatically for the Plugin you can do so, sending the Web Client Id on each projects Initialize method respectively.

  • Relevant Google Documentation about this topic:

Authenticate with a backend server

Get your backend server's OAuth 2.0 client ID


    /* 1st Parameter (MainActivity), 2nd Parameter enables the ServerAuthCode 
    3rd Parameter enables the RequestIdToken. 
    (You pass the server web client id to both parameters).
    GoogleClientManager.Initialize(this, "Xewa3121FDvbam", "Xewa3121FDvbam");

After applying this changes, you should now be able to see that your ActiveToken no longer returns null when you access it on the plugin after a successful login.



Silent Login

If you wish to silently login your users if they have already authenticated on their device without the need to interact with the UI from the Google Sign In SDK and simply set your UI on the Authenticated state.

You can now do this simply calling this line of code:


Enable Additional Scopes and API's

In case you wish to enable additional Scopes and API’s to access different types of information, you can now do so simply by passing in 2 new parameters containing arrays with the scopes and API’s you want to enable on the Google Plugin Initialize method.

Signature of the initialize methods:

//Android initialize method.
public static void Initialize(
            Activity activity,
            string serverClientId = null,
            string clientId = null,
            Api[] apis = null,
            string[] scopes = null)
//iOS initialize method.
public static void Initialize(
            Activity activity,
            string serverClientId = null,
            string clientId = null,
            Api[] apis = null,
            string[] scopes = null)

<= Back to Table of Contents

You can’t perform that action at this time.