Microsoft winsdkfb 未登录:您尚未登录。请登录后重试。 C# WinRT

Microsoft winsdkfb Not Logged In: You are not logged in. Please login and try again. C# WinRT

对于我们新的 Windows 10 应用程序 (C# + XAML),我们正在使用新的 https://github.com/Microsoft/winsdkfb/ 登录名,但是由于我们已经迁移到这个登录名,所以我没有运气Facebook 登录。

我们正在使用 FBResult result = await sess.LoginAsync(permissions);,但我一直收到此错误:"Not Logged In: You are not logged in. Please login and try again."

我的代码完全是从他们在 github 上所做的示例中复制粘贴的: 我检查了我的 SID 和 FacebookAppId,它们在应用程序和 Facebook 网站上都是一样的。

public async Task<string> LogIntoFacebook()
        {
            //getting application Id
            string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

            //// Get active session
            FBSession sess = FBSession.ActiveSession;
            sess.FBAppId = FacebookAppId;
            sess.WinAppId =  SID;

            //setting Permissions
            FBPermissions permissions = new FBPermissions(PermissionList);

            try
            {
                // Login to Facebook
                FBResult result = await sess.LoginAsync(permissions);

                if (result.Succeeded)
                {
                    // Login successful
                    return sess.AccessTokenData.AccessToken;
                }
                else
                {
                    // Login failed
                    return null;
                }
            }
            catch (InvalidOperationException ex)
            {
                SimpleIoc.Default.GetInstance<IErrorService>().ReportErrorInternalOnly(ex);
                return null;
            }
            catch (Exception ex)
            {
                SimpleIoc.Default.GetInstance<IErrorService>().ReportErrorInternalOnly(ex);
                return null;
            }

            return null;
        }

通过这样做:

//getting application Id
string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();

它正在为我生成如下所示的 SID: ms-app://s-1-15-2-0000-bla-bla-bla-667/ 所以我尝试将 ms-app:// 添加到 facebook 开发人员设置页面,但它不需要它,所以我尝试在将它传递给 WinAppId 时从 SID 中删除 ms-app:// 但仍然没有运气

我已填写字段 Windows 用我的 FBAppId 存储 SID:

有人遇到过这个问题吗?

编辑 1: 我的代码是从这里复制和粘贴的:http://microsoft.github.io/winsdkfb/

Edit2:播放来自 Microsoft 的示例我的问题来自我的应用程序 ID。 我确实遵循了第6步: (启用 OAuth 登录)

在尝试了所有方法并且不想使用 WebAuthentificationBroker 之后,我找到了解决方案。

访问 Facebook 开发者网站:https://developers.facebook.com

然后:

转到您的应用名称 -> 设置 -> 高级:

依据:有效的 OAuth 重定向 URI 您需要添加:https://www.facebook.com/connect/login_success.html

保存,您现在就可以开始了!