Friday, March 31, 2017

Facebook OAuth Xamarin Forms Redirection

Leave a Comment

enter image description here

I am using xamarin forms OAuth2 to signin into Facebook, Google and Twitter.

On android it works. But on iOS it screen freezes with spinning activity indicator at top right corner. Is there any one having same issue ?.

Update: Please find below code

partial void UIButton15_TouchUpInside(UIButton sender) {     // https://developers.facebook.com/apps/     var auth = new OAuth2Authenticator(     clientId: "ID",     scope: "",     authorizeUrl: new Uri("https://m.facebook.com/dialog/oauth/"),     redirectUrl: new Uri("http://www.facebook.com/connect/login_success.html"));      var ui = auth.GetUI();      auth.Completed += FacebookAuth_Completed;      PresentViewController(ui, true, null); }  async void FacebookAuth_Completed(object sender, AuthenticatorCompletedEventArgs e) {     if (e.IsAuthenticated)     {         var request = new OAuth2Request(             "GET",             new Uri("https://graph.facebook.com/me?fields=name,picture,cover,birthday"),             null,             e.Account);          var fbResponse = await request.GetResponseAsync();         var fbUser = JsonValue.Parse(fbResponse.GetResponseText());         var name = fbUser["name"];         var id = fbUser["id"];         var picture = fbUser["picture"]["data"]["url"];         var cover = fbUser["cover"]["source"];     }     DismissViewController(true, null); } 

On facebook developer site:

Created app using Facebook login plugin. Added redirect URL as http://www.facebook.com/connect/login_success.html

0 Answers

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment