Skip to content

Commit

Permalink
authentication: using a custom refresh function for Azure CLI Authent…
Browse files Browse the repository at this point in the history
…ication

fixes #22
  • Loading branch information
tombuildsstuff committed Oct 20, 2019
1 parent c443704 commit a2cb447
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions authentication/auth_method_azure_cli_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ func (a azureCliTokenAuth) getAuthorizationToken(sender autorest.Sender, oauth *
return nil, err
}

var refreshFunc adal.TokenRefresh = func(ctx context.Context, resource string) (*adal.Token, error) {
token, err := obtainAuthorizationToken(resource, a.profile.subscriptionId)
if err != nil {
return nil, err
}

adalToken, err := token.ToADALToken()
if err != nil {
return nil, err
}

return &adalToken, nil
}
spt.SetCustomRefreshFunc(&refreshFunc)

auth := autorest.NewBearerAuthorizer(spt)
return auth, nil
}
Expand Down

0 comments on commit a2cb447

Please sign in to comment.