[英]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.