Skip to content

Commit 23a5fdd

Browse files
authored
fix(auth): pass username argument to OAuth2Flow in auth oauth2 command (#60)
The `auth oauth2` command always passes an empty string to `OAuth2Flow()`, ignoring any positional username argument. This forces the flow through `fetchUsername()` which calls `GET /2/users/me` — an endpoint that has been returning 403 for many developers since the March 2026 platform regression. When a username is provided (`xurl auth oauth2 alice`), pass it through so `OAuth2Flow` skips the broken `/2/users/me` lookup and stores the token under the given username directly. Fixes #47
1 parent e149127 commit 23a5fdd

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

cli/auth.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,15 @@ func createAuthBearerCmd(a *auth.Auth) *cobra.Command {
5656

5757
func createAuthOAuth2Cmd(a *auth.Auth) *cobra.Command {
5858
cmd := &cobra.Command{
59-
Use: "oauth2",
59+
Use: "oauth2 [USERNAME]",
6060
Short: "Configure OAuth2 authentication",
61+
Args: cobra.MaximumNArgs(1),
6162
Run: func(cmd *cobra.Command, args []string) {
62-
_, err := a.OAuth2Flow("")
63+
username := ""
64+
if len(args) > 0 {
65+
username = args[0]
66+
}
67+
_, err := a.OAuth2Flow(username)
6368
if err != nil {
6469
fmt.Println("OAuth2 authentication failed:", err)
6570
os.Exit(1)

0 commit comments

Comments
 (0)