GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — show token scopes on auth status by mntlty · Pull Request #6546 · cli/cli Conversation
|
| ghAPI "github.com/cli/go-gh/pkg/api" |
I also added some documentation to the httpmock.REST command.
Output looks like:
In the case that no scopes are found, the output will say
X Token Scopes: None found
There are different prefixes for token types https://github.blog/2022-10-18-introducing-fine-grained-personal-access-tokens-for-github/
Server-to-server and Fine grained permissions tokens do not contain the "X-Oauth-Scopes" header, which would make the output above confusing. In those cases, we show a warning to the user.
For a fine-grained token (prefixed with github_pat_):
github.com
X github.com: api call failed: non-200 OK status code: 401 Unauthorized body: "{\"message\":\"Personal access tokens with fine grained access do not support the GraphQL API\",\"documentation_url\":\"https://docs.github.com/graphql/guides/forming-calls-with-graphql#authenticating-with-graphql\"}"
✓ Logged in to github.com as (GH_TOKEN)
✓ Git operations for github.com configured to use ssh protocol.
✓ Token: *******************
! Cannot determine scopes for fine-grained token.
For a server-to-server token (prefixed with ghs_):
github.com
✓ Logged in to github.com as mntlty-test[bot] (GH_TOKEN)
✓ Git operations for github.com configured to use ssh protocol.
✓ Token: *******************
! Cannot determine scopes for server-to-server token.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the contribution. I pushed a small 💅 commit to cleanup some small style nits I had.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Almost there! Thank you @mntlty
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if scopesHeader != "" { | ||
| addMsg("%s Token Scopes: %s", cs.SuccessIcon(), scopesHeader) | ||
| } else { | ||
| addMsg("%s Token Scopes: None found", cs.Red("X")) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Rendering this as an error in red color might be misleading for Integration tokens and PAT v2, which have a concept of "permissions" but not scopes, and thus do not render any x-oauth-scopes response header.
Maybe it's best to just not render information about "scopes" in that case and instead print the type of token used?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@mislav thanks, I made the changes and updated the PR body to reflect if we don't know the token type and offer more information. If you think it's clearer, I can remove it entirely in those cases.
Thinking about this, I wonder if
I feel like these may be out of scope from the original issue, but wanted to bring them up.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
- show path to config file - display token prefix - refine how missing scopes are shown
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mntlty for the contribution and @samcoe for reviewing.
I've pushed some changes:
The {host} token in {source} is no longer valid.{source} is now a file path to hosts.yml instead of a hardcoded string oauth_token (which might be a bug in go-gh)ghp_ unmasked so that the user can inspect which type of token they are usinggh auth status tests now assert exact command output instead of matching with regexp
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@mislav can this be merged? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yes. I guess that because the scope of my added changes, I wanted to give you a chance to weigh in. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Show token scopes ingh auth status
There was an error while loading. Please reload this page.