2017-03-21 61 views
6

enter image description here的Facebook的OAuth Xamarin窗体重定向

我使用xamarin形式的OAuth2来签到到Facebook,谷歌和Twitter。

在Android上它工作。但是在iOS上,它的屏幕冻结在右上角的旋转活动指示器上。有没有人有同样的问题?

更新:请从下面的代码

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); 
} 

在Facebook开发者网站:

使用Facebook登录插件创建应用程序。 添加重定向网址为http://www.facebook.com/connect/login_success.html

+0

Xamarin.Auth您使用的是什么版本?还有在日志控制台中显示任何错误/消息? – apineda

+0

感谢您的评论。控制台上没有错误消息。我正在使用1.3.0。也试过最新的1.3.2.7。 –

+0

更新显示您用于通过Facebook进行身份验证的代码的帖子 – apineda

回答

0

似乎只有最新的OAuth库才会发生问题。由于构建错误,无法使用先前版本的OAuth进行构建。所以创建了基于Webview的登录,然后是Graph API Request。