-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unmarshal expires_in outside of oauth2/internal #484
Comments
Good point. I mentionned something about it in my latest post: http://www.zakariaamine.com/2021-03-23/leveraging_oauth2_package_golang This logic here https://github.com/golang/oauth2/blob/master/internal/token.go#L262 needs to be duplicated:
However, nothing garantees that the time you (as a user) unmarshall a token, is the exact time of the token obtention. This can lead to |
Imho that‘s a smaller concern, addressable via docs, and already true with the internal handling today. |
This is one of the patterns that seems to come up a lot: https://cs.github.com/?scopeName=All+repos&scope=&q=language%3Agolang+ExpiresIn+int#. An alternative way of achieving the same result could be using Line 188 in 9780585
|
unforutnately anything under /internal/ cannot be exported and used by other librairies (as per Go specs) |
Fixing this would surely break backwards compatibility? Nevertheless easy marshalling between oauth2.Token and RFC 6749 Access Token Response JSON is desirable. Maybe this has to wait until the next major version? |
Migrated to golang/go#61417 |
Some almost-OAuth2 apis return
expires_in
as part of their token response. Unfortunately, unmarshaling into anoauth2.Token
does not populate it'sExpiry
field. Hence, the token structure needs be duplicated/embedded to provide this logic. It would be nice ifoauth2.Token.UnmarshalJSON
populated theExpiry
field whenexpires_in
is populated.The text was updated successfully, but these errors were encountered: