Merge pull request #1510 from dmcgowan/oauth-offline-access
Add offline token option
This commit is contained in:
commit
274825f403
@ -116,6 +116,7 @@ type tokenHandler struct {
|
|||||||
transport http.RoundTripper
|
transport http.RoundTripper
|
||||||
clock clock
|
clock clock
|
||||||
|
|
||||||
|
offlineAccess bool
|
||||||
forceOAuth bool
|
forceOAuth bool
|
||||||
clientID string
|
clientID string
|
||||||
scopes []Scope
|
scopes []Scope
|
||||||
@ -149,6 +150,7 @@ type TokenHandlerOptions struct {
|
|||||||
Transport http.RoundTripper
|
Transport http.RoundTripper
|
||||||
Credentials CredentialStore
|
Credentials CredentialStore
|
||||||
|
|
||||||
|
OfflineAccess bool
|
||||||
ForceOAuth bool
|
ForceOAuth bool
|
||||||
ClientID string
|
ClientID string
|
||||||
Scopes []Scope
|
Scopes []Scope
|
||||||
@ -182,6 +184,7 @@ func NewTokenHandlerWithOptions(options TokenHandlerOptions) AuthenticationHandl
|
|||||||
handler := &tokenHandler{
|
handler := &tokenHandler{
|
||||||
transport: options.Transport,
|
transport: options.Transport,
|
||||||
creds: options.Credentials,
|
creds: options.Credentials,
|
||||||
|
offlineAccess: options.OfflineAccess,
|
||||||
forceOAuth: options.ForceOAuth,
|
forceOAuth: options.ForceOAuth,
|
||||||
clientID: options.ClientID,
|
clientID: options.ClientID,
|
||||||
scopes: options.Scopes,
|
scopes: options.Scopes,
|
||||||
@ -346,6 +349,10 @@ func (th *tokenHandler) fetchTokenWithBasicAuth(realm *url.URL, service string,
|
|||||||
reqParams.Add("scope", scope)
|
reqParams.Add("scope", scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if th.offlineAccess {
|
||||||
|
reqParams.Add("offline_token", "true")
|
||||||
|
}
|
||||||
|
|
||||||
if th.creds != nil {
|
if th.creds != nil {
|
||||||
username, password := th.creds.Basic(realm)
|
username, password := th.creds.Basic(realm)
|
||||||
if username != "" && password != "" {
|
if username != "" && password != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user