I'm trying to establish a google oAuth2 client with golang.org/x/oauth2/google
so that I can schedule some email reminders for myself. If I understand the documentation correctly, the rough process goes like this.
oauth2.Config
instanceThe trouble I'm having is that all of the functions for generating config with golang.org/x/oauth2/google
seem to require a local credential file from which to read what I assume are Google API Client id and Client secrets.
That's fine for a persistent runtime but this application will be running in a volatile location without a disk. I feel like I must be missing some obvious way to create the config using my api client id and secret that I have stored in the environment. Am I using this package incorrectly? How can I create an instance of oauth2.Config
without having a local file?
I can think of a couple of things you can do:
1) There is a ConfigFromJSON
function that gets a JSON document as []byte. You can figure out what that file looks like, and generate it using the environment variables.
2) It looks like all the package does is to prepare an oauth2 config. You can prepare the config yourself with the credentials you have, bypassing the library completely.