简体   繁体   English

如何使用Facebook graph API从应用程序令牌转换为页面令牌?

[英]How do I convert from an app token to a page token using the Facebook graph API?

I'm using the Facebook .NET SDK. 我正在使用Facebook .NET SDK。

I can generate an app access like so: 我可以像这样生成应用访问权限:

var client = new FacebookClient();
dynamic appAccessToken =
            client.Get(
                string.Format("/oauth/access_token?client_id={0}&client_secret={1}&grant_type=client_credentials", appId, appSecret));

which brings me back an access token in the format {appId}|{token} 这使我以{appId}|{token}格式返回访问令牌

If I then pass this back into the client object I hoped to get a page access token, but I'm just getting back the page Id, where I as expecting to get the page Id and an access token. 如果然后将其传递回客户端对象,则希望获得页面访问令牌,但我只是返回页面ID,我希望在那里获得页面ID和访问令牌。

Full code: 完整代码:

var client = new FacebookClient();
dynamic appAccessToken =
            client.Get(
                string.Format("/oauth/access_token?client_id={0}&client_secret={1}&grant_type=client_credentials", appId, appSecret));
client.AccessToken = appAccessToken.access_token;
dynamic tokens = client.Get(string.Format("/v2.5/{0}?fields=access_token", pageId));

To get a Page Token, you need to authorized with the manage_pages permission and use the /me/accounts endpoint to get Page Tokens for all your Pages. 要获取页面令牌,您需要获得manage_pages权限的授权,并使用/me/accounts端点获取所有页面的页面令牌。 Or /page-id?fields=access_token for a single Page. /page-id?fields=access_token单个页面。 You MUST use a User Token with manage_pages though, you can´t just use an App Token. 不过,您必须将用户令牌与manage_pages使用,而不能仅使用应用程序令牌。 App Tokens are not tied to a User (and the Pages he manages). 应用令牌不与用户(以及他管理的页面)绑定。

More information: 更多信息:

Make sure you understand the difference between App Token, User Token and Page Token. 确保您了解应用令牌,用户令牌和页面令牌之间的区别。 And of course you can´t get a Page Token for Pages you don´t manage, just in case it´s not clear. 当然,如果您不清楚,您将无法获得您无法管理的页面的页面令牌。

暂无
暂无

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

相关问题 如何在不审查我的Facebook应用程序的情况下使用Graph API发布到Facebook页面? - How do I post to a Facebook Page using the Graph API without having my Facebook App reviewed? 如何使用Facebook graph API判断用户是否在线? - Using the Facebook graph API how do I tell if a user is online or not? Facebook Graph API-access_token = app_id | app_secret-搜索Graph API,无需用户登录 - Facebook Graph API - access_token=app_id|app_secret - search Graph API without user login 如何获取应用程序的Facebook访问令牌以在公司墙上发布? - How do I obtain a Facebook access token for an app to post on a company wall? 如何使用令牌 API 从 ADO 获取令牌到期日期? - How to get token expiration date from ADO using token API? 如何使用控制台应用程序使用Facebook graph api在我自己的facebook页面上发布照片? - How can I post photo on my own facebook page with facebook graph api using console application? 如何使用Facebook API以编程方式获取身份验证令牌? - How to get authentication token programmatically using facebook api? Facebook使用应用程序访问令牌发布照片 - Facebook Posting Photo using App Access Token 将令牌从经过身份验证的应用程序传递到另一个 API 以使用 OBO 流到图形 API - Passing a token from an authenticated app to another API to use OBO flow to Graph API Azure AD - 在 C# Web API 中使用来自 Angular SPA 的图 API 访问令牌 - Azure AD - Using Graph API access token from Angular SPA in C# Web API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM