public GoogleDataModel(GoogleEntity entity) { Email = entity.Email; AccessToken = entity.AccessToken; RefreshToken = entity.RefreshToken; ClientId = entity.RefreshToken; }
public GoogleServiceViewModel() { Services = new ObservableCollection <GoogleDataModel>(); LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand()); MessagingCenter.Subscribe <GooglePage, GoogleDataModel>(this, "AddGoogleAccount", async(obj, item) => { var newModel = new GoogleEntity(item); await DbProvider.AddOrUpdateAsync(newModel); Services.Add(new GoogleDataModel(newModel)); new Command(async() => await ExecuteLoadItemsCommand()).Execute(null); }); }
public async Task <ActionResult> ExternalLoginCallback() { Account account = null; var info = await AuthenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return(RedirectToAction("Index", "Home")); } if (info.Login.LoginProvider == "Facebook") { FacebookClient fb = new FacebookClient(); var identity = AuthenticationManager.GetExternalIdentity(DefaultAuthenticationTypes.ExternalCookie); var accessToken = identity.FindFirstValue(FacebookAccessToken); fb.AccessToken = accessToken; var facebookInfo = fb.Get(ConfigurationManager.AppSettings["FacebookUri"]); FacebookEntity facebookEntity = JsonConvert.DeserializeObject <FacebookEntity>(facebookInfo.ToString()); account = new Account(); account.Id = facebookEntity.Id; account.Name = facebookEntity.Name; account.Email = facebookEntity.Email; account.FirstName = facebookEntity.first_name; account.LastName = facebookEntity.last_name; } else if (info.Login.LoginProvider == "Google") { string googleInfo = info.ExternalIdentity.Claims.FirstOrDefault(c => c.Type == "GoogleInfo").Value; GoogleEntity ObjectGoogle = JsonConvert.DeserializeObject <GoogleEntity>(googleInfo); account = new Account(); account.Id = ObjectGoogle.id; account.Name = ObjectGoogle.name; account.Email = ObjectGoogle.email; account.FirstName = ObjectGoogle.given_name; account.LastName = ObjectGoogle.family_name; } return(View("ExternalLoginConfirmation", account)); }