This directory contains support code that can be used to get an OAuth2 token for a Google API user.
It is designed to work on computers with attached displays. Use it to write command-line tools and test programs that call Google APIs.
Import this package and make the following call to request a token.
client, err := googleauth.NewOAuth2Client(scopes)
scopes
should be a string containing the OAuth scopes needed by the APIs to be called. For example, the URL Shortener API would require “https://www.googleapis.com/auth/urlshortener”.
This call will then open a local browser that will redirect to a Google signin page with information about the app that is requesting a token.
To use this package, you need to download a “client secrets” file and save it as client_secrets.json
in the directory where your tool is run.
To get this file, visit the {{ Google Cloud Console }}{{ https://cloud.google.com/console }} and create a project. Then go to the API Manager to enable the APIs that you want to use and create OAuth2 credentials. You'll then be able to download these credentials as JSON. Save this file as client_secrets.json
For more information about the client_secrets.json
file format, please visit: https://developers.google.com/api-client-library/python/guide/aaa_client_secrets