feat: support verification_url workaround for DeviceAuthorizationResponse unmarshal (#577)
This commit is contained in:
parent
33485b82ba
commit
e75a061807
2 changed files with 52 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
package oidc
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// DeviceAuthorizationRequest implements
|
||||
// https://www.rfc-editor.org/rfc/rfc8628#section-3.1,
|
||||
// 3.1 Device Authorization Request.
|
||||
|
@ -20,6 +22,26 @@ type DeviceAuthorizationResponse struct {
|
|||
Interval int `json:"interval,omitempty"`
|
||||
}
|
||||
|
||||
func (resp *DeviceAuthorizationResponse) UnmarshalJSON(data []byte) error {
|
||||
type Alias DeviceAuthorizationResponse
|
||||
aux := &struct {
|
||||
// workaround misspelling of verification_uri
|
||||
// https://stackoverflow.com/q/76696956/5690223
|
||||
// https://developers.google.com/identity/protocols/oauth2/limited-input-device?hl=fr#success-response
|
||||
VerificationURL string `json:"verification_url"`
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(resp),
|
||||
}
|
||||
if err := json.Unmarshal(data, &aux); err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.VerificationURI == "" {
|
||||
resp.VerificationURI = aux.VerificationURL
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeviceAccessTokenRequest implements
|
||||
// https://www.rfc-editor.org/rfc/rfc8628#section-3.4,
|
||||
// Device Access Token Request.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue