Skip to content

Commit

Permalink
auth/live.go: Added RefreshTokenSourceWriter (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flonja committed Jul 29, 2022
1 parent f898f01 commit f397a53
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion minecraft/auth/live.go
Expand Up @@ -51,7 +51,15 @@ func (src *tokenSource) Token() (*oauth2.Token, error) {
// refreshes the token everytime it expires. Note that this function must be used over oauth2.ReuseTokenSource
// due to that function not refreshing with the correct scopes.
func RefreshTokenSource(t *oauth2.Token) oauth2.TokenSource {
return oauth2.ReuseTokenSource(t, &tokenSource{w: os.Stdout, t: t})
return RefreshTokenSourceWriter(t, os.Stdout)
}

// RefreshTokenSourceWriter returns a new oauth2.TokenSource using the oauth2.Token passed that automatically
// refreshes the token everytime it expires. It requests from io.Writer if the oauth2.Token is invalid.
// Note that this function must be used over oauth2.ReuseTokenSource due to that
// function not refreshing with the correct scopes.
func RefreshTokenSourceWriter(t *oauth2.Token, w io.Writer) oauth2.TokenSource {
return oauth2.ReuseTokenSource(t, &tokenSource{w: w, t: t})
}

// RequestLiveToken does a login request for Microsoft Live Connect using device auth. A login URL will be
Expand Down

0 comments on commit f397a53

Please sign in to comment.