Is there a way to list a personal access token's scopes using Octokit/rest.js?

六月ゝ 毕业季﹏ 提交于 2019-12-24 19:34:05

问题


We use Octokit to automate some workflows at work, but most of the time the issues we have is that the users haven't set-up their personal access token correctly, with the right scopes.

We would like to have a check before the app runs, to check if the token given has the right scope and give the engineer a meaningful error message right in the beginning, instead of failing later in the process.


回答1:


Yes, the scopes for a personal access token is listed in the response header, you can access it like this

const { headers } = await octokit.request('HEAD /')
const scopes = headers['x-oauth-scopes'].split(', ')

See: Understanding scopes for OAuth Apps



来源:https://stackoverflow.com/questions/56006959/is-there-a-way-to-list-a-personal-access-tokens-scopes-using-octokit-rest-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!