Last active
October 15, 2017 21:23
-
-
Save DanielCauser/2cbb86dc2b1ac9c0ad815f763dfe5c8b to your computer and use it in GitHub Desktop.
XamarinAuth.Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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