From 14b275c918cfd6590f412031b27f6ff0d8fd17c5 Mon Sep 17 00:00:00 2001 From: M Hickford Date: Fri, 22 Sep 2023 20:41:25 +0000 Subject: [PATCH] oauth2: workaround misspelling of verification_uri Some servers misspell verification_uri as verification_url, contrary to spec RFC 8628 Example server https://issuetracker.google.com/issues/151238144 Fixes #666 Change-Id: I89e354368bbb0a4e3b979bb547b4cb37bbe1cc02 GitHub-Last-Rev: bbf169b52d7e5c375da31c664adafc2423d22a8f GitHub-Pull-Request: golang/oauth2#667 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/527835 TryBot-Result: Gopher Robot Reviewed-by: Nikolay Turpitko Auto-Submit: Bryan Mills Reviewed-by: Matthew Dempsky Reviewed-by: Bryan Mills Run-TryBot: Matt Hickford --- deviceauth.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/deviceauth.go b/deviceauth.go index 85ef796..e99c92f 100644 --- a/deviceauth.go +++ b/deviceauth.go @@ -59,6 +59,8 @@ func (c *DeviceAuthResponse) UnmarshalJSON(data []byte) error { type Alias DeviceAuthResponse aux := &struct { ExpiresIn int64 `json:"expires_in"` + // workaround misspelling of verification_uri + VerificationURL string `json:"verification_url"` *Alias }{ Alias: (*Alias)(c), @@ -69,6 +71,9 @@ func (c *DeviceAuthResponse) UnmarshalJSON(data []byte) error { if aux.ExpiresIn != 0 { c.Expiry = time.Now().UTC().Add(time.Second * time.Duration(aux.ExpiresIn)) } + if c.VerificationURI == "" { + c.VerificationURI = aux.VerificationURL + } return nil }