Skip to content

Commit b7f5d7f

Browse files
committed
workaround verification_url
1 parent 2d9e4a2 commit b7f5d7f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

deviceauth.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ func (d DeviceAuthResponse) MarshalJSON() ([]byte, error) {
5757
func (c *DeviceAuthResponse) UnmarshalJSON(data []byte) error {
5858
type Alias DeviceAuthResponse
5959
aux := &struct {
60-
ExpiresIn int64 `json:"expires_in"`
60+
ExpiresIn int64 `json:"expires_in"`
61+
VerificationURL string `json:"verification_url"`
6162
*Alias
6263
}{
6364
Alias: (*Alias)(c),
@@ -68,6 +69,10 @@ func (c *DeviceAuthResponse) UnmarshalJSON(data []byte) error {
6869
if aux.ExpiresIn != 0 {
6970
c.Expiry = time.Now().UTC().Add(time.Second * time.Duration(aux.ExpiresIn))
7071
}
72+
// some services return verification_url instead of verification_uri
73+
if c.VerificationURI == "" && aux.VerificationURL != "" {
74+
c.VerificationURI = aux.VerificationURL
75+
}
7176
return nil
7277
}
7378

0 commit comments

Comments
 (0)