简体   繁体   English

使用 UWP 应用连接到 Facebook

[英]Connecting to Facebook with UWP Apps

I am trying to get an authentication by Facebook on a UWP project.我正在尝试通过 Facebook 对 UWP 项目进行身份验证。

This method keeps failing:此方法不断失败:

FacebookService.Instance.Initialize(FacebookClientID.Text, FacebookPermissions.Email);
var log = await FacebookService.Instance.LoginAsync();
if (log)
{
    return;
}

This method fails with "User cancelled the dialog flow":此方法因“用户取消对话流”而失败:

FBSession session = FBSession.ActiveSession;
session.WinAppId = SID;
session.FBAppId = APPid;
List<string> permissionList = new List<string>();
permissionList.Add("public_profile");
permissionList.Add("email");
FBPermissions permissions = new FBPermissions(permissionList);
var result = await session.LoginAsync(permissions);
if (result.Succeeded)
{
    //do something
}

For creating and configuring FaceBook app that used to UWP client app, you need to refer Facebook Service official document.用于创建和配置用于 UWP 客户端应用程序的FaceBook应用程序,您需要参考Facebook Service官方文档。

The Windows Store SID is a unique value per application generated, and it not tied to the actual store publication. Windows 应用商店 SID 是每个生成的应用程序的唯一值,它与实际的应用商店发布无关。 Creating a local application will give you a valid SID that you can use for debugging against Facebook.创建本地应用程序将为您提供可用于针对 Facebook 进行调试的有效 SID。

Please use the following code get store id.请使用以下代码获取商店ID。

var id = Microsoft.Toolkit.Uwp.Services.Facebook.FacebookService.Instance.WindowsStoreId;

Remark : From left side menu choose + Add Product Click to add Facebook Login .备注:从左侧菜单中选择 +添加产品点击添加Facebook 登录 Ensure you set the following options in the UI:确保在 UI 中设置以下选项:

在此处输入图片说明

FacebookService.Instance.Initialize("appid");
if (!await FacebookService.Instance.LoginAsync())
{
    return;
}

Update更新

Problem solved.问题解决了。 Apperantly microsoft toolkit based on an old nugget which had to update manually.显然是基于必须手动更新的旧金块的微软工具包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM