public async Task <Models.AppIdentity> Authenticate(MobileKidsIdApp.Services.LoginProviders provider) { Models.AppIdentity result = null; try { #if DEBUG if (provider == MobileKidsIdApp.Services.LoginProviders.Test) { result = await Models.AppIdentity.GetAppIdentityAsync("test:1", "blahblahblah"); return(result); } #endif var client = new MobileServiceClient(Constants.ApplicationURL); MobileServiceUser authnResult = null; switch (provider) { case MobileKidsIdApp.Services.LoginProviders.Google: authnResult = await client.LoginAsync(MobileServiceAuthenticationProvider.Google, Constants.URLScheme); break; case MobileKidsIdApp.Services.LoginProviders.Microsoft: authnResult = await client.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount, Constants.URLScheme); break; case MobileKidsIdApp.Services.LoginProviders.Facebook: authnResult = await client.LoginAsync(MobileServiceAuthenticationProvider.Facebook, Constants.URLScheme); break; default: throw new ArgumentException("LoginProvider"); } result = await Models.AppIdentity.GetAppIdentityAsync(authnResult.UserId, authnResult.MobileServiceAuthenticationToken); } catch { result = new Models.AppIdentity(); } return(result); }
public async Task <AppIdentity> Authenticate(LoginProviders provider) { Models.AppIdentity result = null; try { #if DEBUG if (provider == MobileKidsIdApp.Services.LoginProviders.Test) { result = await Models.AppIdentity.GetAppIdentityAsync("test:1", "blahblahblah"); return(result); } #endif var client = new MobileServiceClient("https://mobilekidsidapp.azurewebsites.net"); MobileServiceUser authnResult = null; switch (provider) { case MobileKidsIdApp.Services.LoginProviders.Google: authnResult = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Google); break; case MobileKidsIdApp.Services.LoginProviders.Microsoft: authnResult = await client.LoginAsync(this, MobileServiceAuthenticationProvider.MicrosoftAccount); break; case MobileKidsIdApp.Services.LoginProviders.Facebook: authnResult = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Facebook); break; default: throw new ArgumentException("LoginProvider"); } result = await Models.AppIdentity.GetAppIdentityAsync(authnResult.UserId, authnResult.MobileServiceAuthenticationToken); } catch { result = new Models.AppIdentity(); } return(result); }
public async Task <AppIdentity> Authenticate(LoginProviders provider) { Models.AppIdentity result = null; try { #if DEBUG if (provider == MobileKidsIdApp.Services.LoginProviders.Test) { result = await Models.AppIdentity.GetAppIdentityAsync("test:1", "blahblahblah"); return(result); } #endif //TODO: switch to latest authentication model //var client = new MobileServiceClient("https://mobilekidsidapp.azurewebsites.net"); //MobileServiceUser authnResult = null; //switch (provider) //{ // case MobileKidsIdApp.Services.LoginProviders.Google: // authnResult = await client.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController, MobileServiceAuthenticationProvider.Google); // break; // case MobileKidsIdApp.Services.LoginProviders.Microsoft: // authnResult = await client.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController, MobileServiceAuthenticationProvider.MicrosoftAccount); // break; // case MobileKidsIdApp.Services.LoginProviders.Facebook: // authnResult = await client.LoginAsync(UIApplication.SharedApplication.KeyWindow.RootViewController, MobileServiceAuthenticationProvider.Facebook); // break; // default: // throw new ArgumentException("LoginProvider"); //} //result = await Models.AppIdentity.GetAppIdentityAsync(authnResult.UserId, authnResult.MobileServiceAuthenticationToken); } catch { result = new Models.AppIdentity(); } return(result); }
public async Task<AppIdentity> Authenticate(LoginProviders provider) { Models.AppIdentity result = null; try { #if DEBUG if (provider == MobileKidsIdApp.Services.LoginProviders.Test) { result = await Models.AppIdentity.GetAppIdentityAsync("test:1", "blahblahblah"); return result; } #endif var client = new MobileServiceClient("https://mobilekidsidapp.azurewebsites.net"); MobileServiceUser authnResult = null; switch (provider) { case MobileKidsIdApp.Services.LoginProviders.Google: authnResult = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Google); break; case MobileKidsIdApp.Services.LoginProviders.Microsoft: authnResult = await client.LoginAsync(this, MobileServiceAuthenticationProvider.MicrosoftAccount); break; case MobileKidsIdApp.Services.LoginProviders.Facebook: authnResult = await client.LoginAsync(this, MobileServiceAuthenticationProvider.Facebook); break; default: throw new ArgumentException("LoginProvider"); } result = await Models.AppIdentity.GetAppIdentityAsync(authnResult.UserId, authnResult.MobileServiceAuthenticationToken); } catch { result = new Models.AppIdentity(); } return result; }