Dam*_*ien 5 c# facebook windows-runtime facebook-login windows-10
对于我们新的Windows 10应用程序(C#+ XAML),我们使用新的https://github.com/Microsoft/winsdkfb/登录,但是因为我们已经迁移到此登录,所以我没有运气登录facebook.
我们正在使用FBResult result = await sess.LoginAsync(permissions);并且我一直收到此错误:"未登录:您尚未登录.请登录并重试."
我的代码是他们在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;
}
Run Code Online (Sandbox Code Playgroud)
通过做这个:
//getting application Id
string SID = WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
Run Code Online (Sandbox Code Playgroud)
它正在生成一个看起来像这样的SID:ms-app:// s-1-15-2-0000-bla-bla-bla-667 /所以我尝试将ms-app://添加到facebook开发者设置中页面,但它不想要它,所以我尝试从SID中删除ms-app://传递给它WinAppId但仍然没有运气
我用我的FBAppId填充了Windows Store SID字段:

有没有人有这个问题?
编辑1:我的代码是从这里复制并粘贴的:http://microsoft.github.io/winsdkfb/
Edit2:播放来自Microsoft的样本我的问题来自我的应用程序ID.我确实按照步骤6 :(启用OAuth登录)
在尝试了所有内容并且不想使用WebAuthentificationBroker后,我找到了解决方案.
访问Facebook Developer网站:https://developers.facebook.com
然后:
转到您的应用名称 - >设置 - >高级:
在:您需要添加的有效OAuth重定向URI:https://www.facebook.com/connect/login_success.html