On Sun, Sep 8, 2019 at 10:59 PM Grigorii Tkachuk <
tkac...@gmail.com> wrote:
>
> I'm looking into this example
https://github.com/gsuitedevs/go-samples/blob/master/gmail/quickstart/quickstart.go and I do not understand why it refreshes "token.json". On line 45 we are passing token itself but not a path to token file. I went thru a documentation and source code but I do not understand how it works. My goal to put service which interacts with gmail api inside k8s cluster and I'm searching a way to pass and store token using k8s secrets but in the first of all I want to understand how it works with files.
It looks like it is using oauth2. It helps if you understand how
oauth2 works. In short, it is authenticating with the server using
some credentials from a file, and then using an already existing token
if there is one (token.json), or requesting a new token using an
authorization code if there isn't one, and storing it in token,json.
All interactions with the server will use that token after that.
The token (probably a jwt) stores the scopes you can access, and it
usually has an expiration date. When the token expires, you have to
reauthenticate and get a new token, or use a refresh token if there is
one. So in your case, I suggest you figure out if those tokens expire.
If they do, then you'd have to manually get tokens and update your k8s
secrets and bounce your pods to update them when you get new tokens.
An alternative would be to store the tokens in a database so they can
be shared between pods without a need for an update and bounce.
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
golang-nuts...@googlegroups.com.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/d3d55244-5d75-464a-86af-8ce5a4eaa09b%40googlegroups.com.