Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions cmd/auth/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,18 @@ func runInlineLogin(ctx context.Context, profiler profile.Profiler, tokenStore s
u2m.WithOAuthArgument(oauthArgument),
u2m.WithBrowser(func(url string) error { return browser.Open(ctx, url) }),
}

// Challenge uses the context passed to NewPersistentAuth, so the timeout
// must be set before it.
ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()

persistentAuth, err := u2m.NewPersistentAuth(ctx, persistentAuthOpts...)
if err != nil {
return "", nil, err
}
defer persistentAuth.Close()

ctx, cancel := context.WithTimeout(ctx, defaultTimeout)
defer cancel()

token, err := persistentAuth.Challenge()
if err != nil {
return "", nil, err
Expand Down
Loading