Suggestion to extend x/OAuth2 API

102 views
Skip to first unread message

cpu...@gmail.com

unread,
Apr 22, 2021, 12:10:38 PM4/22/21
to golang-nuts
After working with a few more-or-less OAuth2 APIs lately, I would like to propose slightly extending the API footprint of the oauth2 library. 

By doing so I expect that the amount of userland/provider-specific code can be reduced- both inside oauth2 and outside in realworld applications. Some of the ideas have been proposed in https://github.com/golang/oauth2/issues/483 and https://github.com/golang/oauth2/issues/484.

Most notably, it would be nice if OAuth2 could cater for the following situations:
- OAuth2 tokens with `expires_in` field (already handled by internal and in some of the OAuth2 providers)
- Add a `TokenRefresher` interface (currently implemented by `tokenRefresher`) that can be passed to a `ReuseTokenSource` for performing the actual token refresh to allow more flexible refresh scenarios.

With these two changes, x/oauth2 could be more widely used without need for reimplementation of the above parts plus might deduplicate parts of the implemented providers.

Hope the above points make sense, happy to take feedback.

Cheers,
Andi

cpu...@gmail.com

unread,
May 9, 2021, 10:17:53 AM5/9/21
to golang-nuts
There is some support for a configurable token source in https://github.com/golang/oauth2/pull/448#issuecomment-835811792, no feedback otherwise.

Cheers,
Andi

Reply all
Reply to author
Forward
0 new messages