forked from remote/oauth2
internal: tolerate malformed expires_in values more
Fixes golang/oauth2#239 Change-Id: Id3fdfbfb64bc1a12ab0e952e83ae444b50de1bb5 Reviewed-on: https://go-review.googlesource.com/c/161964 Reviewed-by: Ross Light <light@google.com> Run-TryBot: Ross Light <light@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
@@ -78,6 +78,9 @@ func (e *tokenJSON) expiry() (t time.Time) {
|
||||
type expirationTime int32
|
||||
|
||||
func (e *expirationTime) UnmarshalJSON(b []byte) error {
|
||||
if len(b) == 0 || string(b) == "null" {
|
||||
return nil
|
||||
}
|
||||
var n json.Number
|
||||
err := json.Unmarshal(b, &n)
|
||||
if err != nil {
|
||||
@@ -257,7 +260,7 @@ func doTokenRoundTrip(ctx context.Context, req *http.Request) (*Token, error) {
|
||||
Raw: vals,
|
||||
}
|
||||
e := vals.Get("expires_in")
|
||||
if e == "" {
|
||||
if e == "" || e == "null" {
|
||||
// TODO(jbd): Facebook's OAuth2 implementation is broken and
|
||||
// returns expires_in field in expires. Remove the fallback to expires,
|
||||
// when Facebook fixes their implementation.
|
||||
|
||||
Reference in New Issue
Block a user