public async Task <bool> SocialLoginFacebook() { try { FbAccessToken token = await Xamarin.Forms.DependencyService.Get <IFacebookLogin>().LogIn(permissions); if (token != null) { // save token await token.Save(); IGraphRequest request = Xamarin.Forms.DependencyService.Get <IGraphRequest>().NewRequest(token, "/me", parameters); IGraphResponse response = await request.ExecuteAsync(); SocialModel socialModel = GetFBData(JObject.Parse(response.RawResponse)); socialModel.AuthType = AuthType.Facebook; await RegisterAndUpdate(socialModel); return(true); } else { System.Diagnostics.Debug.WriteLine("======================token was null"); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } return(false); }
public async Task <bool> HandleAlreadyLoggedIn(FbAccessToken token) { IGraphRequest request = Xamarin.Forms.DependencyService.Get <IGraphRequest>().NewRequest(token, "/me", parameters); IGraphResponse response = await request.ExecuteAsync(); if (response.RawResponse != null) { SocialModel socialModel = GetFBData(JObject.Parse(response.RawResponse)); socialModel.AuthType = AuthType.Facebook; await RegisterAndUpdate(socialModel); return(true); } return(false); }
async void HandleAlreadyLoggedIn(FbAccessToken token) { parameters.Add("fields", "name, email"); IGraphRequest request = DependencyService.Get <IGraphRequest>() .NewRequest(token, "/me", parameters); IGraphResponse response = await request.ExecuteAsync(); System.Diagnostics.Debug.WriteLine(response.RawResponse); Dictionary <string, string> deserialized = JsonConvert .DeserializeObject <Dictionary <string, string> >(response.RawResponse); FacebookProfile profile = new FacebookProfile(deserialized["name"], deserialized["email"], deserialized["id"]); await CoreMethods.PushPageModel <LoggedInPageModel>(profile); }
/// <summary> /// Sends the asynchronous. /// </summary> /// <typeparam name="TRequest">The type of the request.</typeparam> /// <param name="client">The client.</param> /// <param name="request">The request.</param> /// <param name="tenant">The tenant.</param> /// <param name="scenarioId">The scenario identifier.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The <see cref="IGraphResponse{T}" />. /// </returns> public static Task <IGraphResponse> SendAsync <TRequest>( this IGraphClient client, IGraphRequest <TRequest> request, string tenant, Guid scenarioId, CancellationToken cancellationToken = default(CancellationToken)) where TRequest : class { if (!string.IsNullOrWhiteSpace(tenant)) { request.Properties.Add(GraphProperty.Property(HttpConstants.HeaderNames.Tenant, tenant)); } request.Properties.Add(GraphProperty.RequestProperty(HttpConstants.HeaderNames.ScenarioId, scenarioId)); request.Properties.Add(GraphProperty.RequestProperty(HttpConstants.HeaderNames.ClientRequestId, Guid.NewGuid())); return(client.SendAsync <TRequest>(request, cancellationToken)); }