Skip to content

Instantly share code, notes, and snippets.

@DanielCauser
Last active October 15, 2017 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielCauser/2cbb86dc2b1ac9c0ad815f763dfe5c8b to your computer and use it in GitHub Desktop.
Save DanielCauser/2cbb86dc2b1ac9c0ad815f763dfe5c8b to your computer and use it in GitHub Desktop.
XamarinAuth.Sample
using System;
using System.Diagnostics;
using System.Json;
using System.Linq;
using XamainAuthentication.Models;
using XamainAuthentication.Services;
using Xamarin.Auth;
using Xamarin.Forms;
namespace XamainAuthentication.Services
{
public class AuthService
{
public static OAuth2Authenticator Authenticator { get; private set; }
public void Authenticate(LoginTypeEnum type)
{
var account = AccountStore.Create().FindAccountsForService(Constants.AppName).FirstOrDefault();
if (account != null)
return;
switch (type)
{
case LoginTypeEnum.Facebook:
FacebookAuth();
break;
case LoginTypeEnum.Twitter:
TwitterAuth();
break;
case LoginTypeEnum.Instagram:
InstagramAuth();
break;
case LoginTypeEnum.Google:
GoogleAuth();
break;
default:
break;
}
Authenticator.Completed += Authenticator_Completed;
Authenticator.Error += Authenticator_Error;
var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(Authenticator);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment