You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Updated config is not correctly picked up after re-auth #914
When trying to use gh pr checkout, I was prompted to re-auth to add the read:org scope to the OAuth(?) app's permissions. After successfully completing that flow, the CLI still error'd thinking it's still lacking the required scopes.
A second attempt at the same command worked without any problems
Expected vs actual behavior
Given the CLI OAuth does not have the read:org scope
When using gh pr checkout command to checkout a PR locally
And successfully completing the automatic re-auth flow in the browser to add the missing scope
Then it should correctly continue with the checkout flow
Instead, it failed with an error.
Logs
$ gh pr checkout https://github.com/<org>/<repo>/pull/123
Notice: additional authorization required
Press Enter to open github.com in your browser...
Authentication complete. Press Enter to continue...
graphql error: 'Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:org', 'read:discussion'], but your token has only been granted the: ['repo'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens.'
$ gh pr checkout https://github.com/<org>/<repo>/pull/123
Switched to a new branch 'feature/add-deploy-readme'
Thank you! This came up in #762 (comment) and I thought it was a fluke, but now I'm convinced that it's because determineBaseRepo creates its own api.Client instance, so we end up with 2 per lifecycle of a command, and when we update the token in memory of one api.Client it stays stale in the 2nd.
After pairing we cleared up some of my confusion around the auth code. I am fixing determineBaseRepo to not create a second apiClient in another PR but can cherry pick it onto something for this bug.
Activity
mislav commentedon May 13, 2020
Thank you! This came up in #762 (comment) and I thought it was a fluke, but now I'm convinced that it's because
determineBaseRepocreates its ownapi.Clientinstance, so we end up with 2 per lifecycle of a command, and when we update the token in memory of oneapi.Clientit stays stale in the 2nd.Ref. #786
vilmibm commentedon May 13, 2020
ah interesting, so it sounds like the solution is just passing a client pointer to
determineBaseRepo. that would explain it.vilmibm commentedon May 13, 2020
We'll revisit this tomorrow when pairing but this problem persists even with a single apiClient being created in the course of a command run.
vilmibm commentedon May 14, 2020
After pairing we cleared up some of my confusion around the auth code. I am fixing
determineBaseRepoto not create a secondapiClientin another PR but can cherry pick it onto something for this bug.