ghinstallation icon indicating copy to clipboard operation
ghinstallation copied to clipboard

Ability to set Transport token

Open mhemmings opened this issue 5 years ago • 3 comments

Add the ability to set the access token on a Transport. This is useful to create a Transport from a token already known (for example stored in a database) to avoid an unnecessary HTTP request to get a new one.

Also fix the build by changing to new jwt time types.

mhemmings avatar Nov 19 '20 19:11 mhemmings

@bradleyfalzon / @wlynch Let me know what you think :)

mhemmings avatar Nov 19 '20 19:11 mhemmings

I've just noticed the Token() method only returns a string, so there is currently no way to get the expires date out to "save" an access token. Not sure the best way to solve this in a backwards compatible way

mhemmings avatar Nov 19 '20 19:11 mhemmings

Thanks for the PR! I'm a little hesitant to expose the AccessToken type, since the github.InstallationOptions and github.Repository fields aren't meant to be set by the user.

The intent for this change seems very similar to oauth2.ReuseTokenSource (and oauth2.Token contains expiration information). I wonder if we should start exposing Token/TokenSource compatible types 🤔 - @bradleyfalzon what do you think?

wlynch avatar Nov 23 '20 18:11 wlynch