Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(953)

Unified Diff: common/auth/auth.go

Issue 2646543003: server/auth: Add TokenSource call. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | server/auth/addr_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/auth/auth.go
diff --git a/common/auth/auth.go b/common/auth/auth.go
index 9990badb5a9f812c6fd8052e73283a2f0e1f8a56..aa2251226adf1ad6d4fc3a294a964ec9bea79294 100644
--- a/common/auth/auth.go
+++ b/common/auth/auth.go
@@ -224,6 +224,15 @@ type Token struct {
TokenType string `json:"token_type,omitempty"`
}
+// OAuth2Token returns the oauth2.Token containing the same data as tok.
+func (tok *Token) OAuth2Token() *oauth2.Token {
+ return &oauth2.Token{
+ AccessToken: tok.AccessToken,
+ Expiry: tok.Expiry,
+ TokenType: tok.TokenType,
+ }
+}
+
// NewAuthenticator returns a new instance of Authenticator given its options.
//
// The authenticator is essentially a factory for http.RoundTripper that knows
@@ -476,11 +485,7 @@ func (s tokenSource) Token() (*oauth2.Token, error) {
if err != nil {
return nil, err
}
- return &oauth2.Token{
- AccessToken: tok.AccessToken,
- Expiry: tok.Expiry,
- TokenType: tok.TokenType,
- }, nil
+ return tok.OAuth2Token(), nil
}
////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « no previous file | server/auth/addr_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698