Description
Migrated from golang/oauth2#484, refs #56402 (comment)
There are a number of OAuth2 token uses outside of the oauth2 library with the token structure being the common denominator. Unfortunately, unmarshaling JSON into an oauth2.Token
does not populate it's Expiry
field. Hence, the token structure needs be duplicated/embedded to provide this logic as it currently lives in oauth2/internal
.
Proposed solution:
Allow unmarshaling an oauth2.Token from its usual json representation, i.e. containing the expires_in
field.
An implementation choice might be to add a Token.UnmarshalJSON
method though that might imply that (later) adding Token.MarshalJSON
may not make sense given the nature of expires_in
being relative to the current moment.
Consequence of not implementing:
Duplicated code like https://cs.github.com/?scopeName=All+repos&scope=&q=language%3Agolang+ExpiresIn+int#.
Alternatives:
- Duplicated code like https://github.com/evcc-io/evcc/blob/master/util/oauth/token.go#L13
- expose
internal/RetrieveToken
to avoid new methods onToken
like Make RetrieveToken usable by client packages oauth2#354 - providing other means of obtaining tokens in a configurable way from
oauth2.Config
like custom exchange request attribute/header oauth2#533, Config: Refresh Token Request with Custom Parameters oauth2#521 or Add additional headers during token refresh oauth2#483
Metadata
Metadata
Assignees
Type
Projects
Status