10000 Manually get current user name rather than use api client by samcoe · Pull Request #7114 · cli/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Manually get current user name rather than use api client #7114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2023
Merged

Conversation

samcoe
Copy link
Contributor
@samcoe samcoe commented Mar 9, 2023

Fixes #7112

Due to a regression in our auth flow we were trying to retrieve the current user name before setting the authentication token, so the request was failing as unauthenticated. This changes how we retrieve the current user name to specify the auth token. The most direct way to do this was to manually create a http request rather than using the api client as before. The api client does not have any clean way to inject an auth token or header unfortunately. Note that this regression only applied to users who paste in their auth token during login.

@samcoe samcoe requested a review from a team as a code owner March 9, 2023 00:40
@samcoe samcoe self-assigned this Mar 9, 2023
@samcoe samcoe requested review from mislav and vilmibm and removed request for a team March 9, 2023 00:40
@@ -231,3 +232,34 @@ func sshKeyUpload(httpClient *http.Client, hostname, keyFile string, title strin

return add.SSHKeyUpload(httpClient, hostname, f, title)
}

func getCurrentLogin(httpClient httpClient, hostname, authToken string) (string, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more or less equivalent to what happens in api.CurrentLoginName which is why no test changes were necessary.

@samcoe samcoe merged commit 50ddb36 into trunk Mar 9, 2023
@samcoe samcoe deleted the fix-pats branch March 9, 2023 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot use personal access token to authenticate with v2.24.0
2 participants
0