FAQ
Reviewers: adg,

Message:
Hello adg@golang.org (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/goauth2


Description:
goauth2: fix token handling

- use cached token if available
- only overwrite RefreshToken if not empty

Please review this at http://codereview.appspot.com/6494125/

Affected files:
M oauth/oauth.go


Index: oauth/oauth.go
===================================================================
--- a/oauth/oauth.go
+++ b/oauth/oauth.go
@@ -180,7 +180,13 @@
if t.Config == nil {
return nil, OAuthError{"Exchange", "no Config supplied"}
}
- tok := new(Token)
+ var tok *Token
+ if t.TokenCache != nil {
+ tok, _ = t.TokenCache.Token()
+ }
+ if tok == nil {
+ tok = new(Token)
+ }
err := t.updateToken(tok, url.Values{
"grant_type": {"authorization_code"},
"redirect_uri": {t.redirectURL()},
@@ -273,7 +279,9 @@
return err
}
tok.AccessToken = b.Access
- tok.RefreshToken = b.Refresh
+ if len(b.Refresh) > 0 {
+ tok.RefreshToken = b.Refresh
+ }
if b.ExpiresIn == 0 {
tok.Expiry = time.Time{}
} else {

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedSep 12, '12 at 11:06p
activeSep 14, '12 at 7:05a
posts12
users2
websitegolang.org

2 users in discussion

Adg: 6 posts Proppy: 6 posts

People

Translate

site design / logo © 2022 Grokbase