trevoriancox / Xamarin.GoogleAuth

Cross platform plugin for doing Google Authentication for Xamarin iOS and Android apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Xamarin.GoogleAuth

Cross platform plugin for doing Google Authentication for Xamarin iOS and Android apps

Why

The short answer is that Google has updated its security restrictions for OAuth flow. They are not going to allow native web-views to initiate OAuth flows, but rather are encouraging people to use the OS browsers to do so.

How

Here are the basic steps that you need to follow to add Google Authentication into your Xamarin forms application

  1. Setup your Application on the Google developer's console to use OAuth2. Guide here. Make sure you select the Web Application option.

  2. Download this repository and copy over the GoogleAuth, Plugin.GoogleAuth, Plugin.GoogleAuth.Android and Plugin.GoogleAuth.iOS folders into your application and add them into your solution in VS or Xamarin Studio.

  3. Add references to the Plugin.GoogleAuth and Plugin.GoogleAuth.Abstractions projects into your PCL project.

  4. Add references to the Plugin.GoogleAuth.Android and Plugin.GoogleAuth.Abstractions projects into your Android project.

  5. Add references to the Plugin.GoogleAuth.iOS and Plugin.GoogleAuth.Abstractions projects into your Android project.

  6. Inside your platform specific projects initialize the Google Authentication service as shown below.

     	IGoogleAuthenticationService _service;
     	_service = CrossGoogleAuth.Current;
     	Dictionary<string, object> googleSignInConfig = new Dictionary<string, object> {
     		{"clientId", "<client-id>"},
     		{"context", this} // Android only
     	};
     	_service.Init(googleSignInConfig);
    
  7. For further usage details, check out the GoogleAuthSample project in this repository.

TODOs

  1. Convert this into a NuGet package !

About

Cross platform plugin for doing Google Authentication for Xamarin iOS and Android apps

License:BSD 2-Clause "Simplified" License


Languages

Language:C# 67.5%Language:Objective-C 32.5%