public static async Task <bool> IsAlreadyAuthenticated() { // Retrieve any stored account information var accounts = await AccountStoreFactory.Create().FindAccountsForServiceAsync(AppName); var account = accounts.FirstOrDefault(); // If we already have the account info then we are set if (account == null) { return(false); } UpdateViewModel(account); return(true); }
public static async Task FetchGoogleEmailAndPicture(Account account) { var request = new OAuth2Request("GET", new Uri(Constants.UserInfoUrl), null, account); var response = await request.GetResponseAsync(); if (response != null) { var userJson = response.GetResponseText(); var user = JsonConvert.DeserializeObject <User>(userJson); account.Username = user.Email; account.Properties[Constants.EmailAccountProperty] = user.Email; account.Properties[Constants.PhotoAccountProperty] = user.Picture; AccountStoreFactory.Create().Save(account, AppName); UpdateViewModel(account); } await Navigator.Current.AuthenticationComplete(); }