获取当前允许的 OAuth 用户范围

Get the currently allowed scopes of an OAuth user

我想知道如何为使用 GitHub 登录的用户获取当前允许的范围。

目前,我正在维护授权范围的本地副本,但我认为获取 真实 数据可能会更好,以避免可能出现的不一致。

有什么建议吗?

您可以列出所有 your personal access token or if you know the current ID of the access token you're looking for you can retrieve it individually.

这是单个令牌的示例响应。您对 scopes 元素感兴趣:

{
  "id": 1,
  "url": "https://api.github.com/authorizations/1",
  "scopes": [
    "public_repo"
  ],
  "token": "",
  "token_last_eight": "12345678",
  "hashed_token": "25f94a2a5c7fbaf499c665bc73d67c1c87e496da8985131633ee0a95819db2e8",
  "app": {
    "url": "http://my-github-app.com",
    "name": "my github app",
    "client_id": "abcde12345fghij67890"
  },
  "note": "optional note",
  "note_url": "http://optional/note/url",
  "updated_at": "2011-09-06T20:39:23Z",
  "created_at": "2011-09-06T17:26:27Z",
  "fingerprint": "jklmnop12345678"
}