Dav*_*ton 5 facebook facebook-graph-api facebook-c#-sdk windows-10 uwp
我正在构建一个新的通用Windows 10 UWP应用程序,并试图进行Facebook登录.
在Facebook上,我已将我的应用程序的Windows应用程序部分设置为具有我的应用程序的标识符:
Windows:s-1-15-xxxxxxxxxxxx
Windows Phone:fef49b712e5a843cbfeb0c9d780423fc(不是实际的)
在包清单文件中,我添加了以下协议:
MSFT-fef49b712e5a843cbfeb0c9d780423fc
这意味着我将我的redirect_uri参数设置为:
MSFT-fef49b712e5a843cbfeb0c9d780423fc://授权
当在手机上运行时(使用Windows 10 Mobile Preview),该服务运行正常,它打开手机上的Facebook应用程序(使用fbconnect:// authorize?.....),然后进行身份验证,然后打开我的应用程序备份 - 完美!!
但是,在桌面上尝试相同时,它不起作用.在我Launcher.LaunchUriAsync()的标准Facebook网络对话框(https://www.facebook.com/dialog/oauth?....) - 这是因为没有支持Windows 10的Facebook应用程序登录.
将相同内容发送redirect_uri到Facebook,它会打开Web浏览器(Edge)并请求权限等.一旦授予权限,就不会发生任何事情.似乎协议处理不起作用.
任何想法都会有用.
在桌面上,尝试使用WebAuthenticationBroker而不是Launcher.LaunchUriAsync如此示例中所述:http://dotnetbyexample.blogspot.de/2015/06/custom-oauth-login-to-facebook-for.html
private async Task<string> AuthenticateFacebookAsync()
{
try
{
var fb = new FacebookClient();
var redirectUri =
WebAuthenticationBroker.GetCurrentApplicationCallbackUri().ToString();
var loginUri = fb.GetLoginUrl(new
{
client_id = AppId,
redirect_uri = redirectUri,
scope = ExtendedPermissions,
display = "popup",
response_type = "token"
});
var callbackUri = new Uri(redirectUri, UriKind.Absolute);
var authenticationResult =
await
WebAuthenticationBroker.AuthenticateAsync(
WebAuthenticationOptions.None,
loginUri, callbackUri);
return ParseAuthenticationResult(fb, authenticationResult);
}
catch (Exception ex)
{
return ex.Message;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4086 次 |
| 最近记录: |