是否可以通过请求 header 传递 Facebook Graph API 访问令牌?

Is it possible to pass Facebook Graph API access token through request header?

我正在使用 Postman 测试 Facebook Graph API v2.3。 虽然可以通过将访问令牌放入查询字符串来获得响应,如下所示:

https://graph.facebook.com/v2.3/me?access_token=my_access_token

我想知道是否可以对 HTTP 请求 headers 做同样的事情,就像这样:

GET /v2.3/me HTTP/1.1
Host: graph.facebook.com
Authorization: <my_access_token>
Cache-Control: no-cache
Postman-Token: <postman_token>

基于 Whosebug 上的类似问题(即 How should a client pass a facebook access token to the server?),看来这应该是可能的。

对此有什么想法吗?


编辑:

What raised my interest is that, when I used the API Graph Explorer provided by Facebook Developers, it seems that there's no query string in that sandbox either. How does that work?

Facebook API Graph Explorer 请使用查询字符串作为访问令牌。感谢 @CBroe 的回复。

有可能

Authorization: Bearer AccessTokenHere

例如

curl --header "Authorization: Bearer CAAC...ZD" https://graph.facebook.com/me

此答案之前建议使用“OAuth”而不是“Bearer”作为 token type。两者都可以,但“Bearer”是标准中出现的类型。此外,在完成 Facebook 的 OAuth 流程时,他们响应中的 token_typebearer。所以总而言之,“Bearer”更有意义。