-
Notifications
You must be signed in to change notification settings - Fork 492
gcloud: Use service account for API access #23
Copy link
Copy link
Closed
Labels
Description
Rather than setting up OAuth the odd way we're doing it now, it would be better to use Google's Service Accounts to authenticate: https://support.google.com/googleapi/answer/6158849?hl=en#serviceaccounts
- You receive a private key which is stored in JSON (which would need to be stored in creds.json)
- The following GoLang code will give you a HTTPClient that can be used for the rest of the API work:
rawConfig, err := ioutil.ReadFile("./jsoncreds.json")
if err != nil {
panic(err)
}
config, err := google.JWTConfigFromJSON(rawConfig, "https://www.googleapis.com/auth/ndev.clouddns.readwrite")
if err != nil {
panic(err)
}
ctx := context.Background()
hc := config.Client(ctx)
- No more setup with refresh keys or manual authorisation against a google account
Reactions are currently unavailable