Skip to content

Instantly share code, notes, and snippets.

@prantoran
Last active June 5, 2018 12:23
Show Gist options
  • Save prantoran/33c215798201a4f53eee3ab71c9cc615 to your computer and use it in GitHub Desktop.
Save prantoran/33c215798201a4f53eee3ab71c9cc615 to your computer and use it in GitHub Desktop.
jbts, err := json.Marshal(PubSubKey) // assuming the data of the json key is in the PubSubKey struct
if err != nil {
log.Println("could not convert api json to bytes:", err)
return
}
conf, err := google.JWTConfigFromJSON(jbts, "https://www.googleapis.com/auth/pubsub")
if err != nil {
log.Fatal(err)
}
ts := conf.TokenSource(ctx)
client, err := pubsub.NewClient(ctx, config.ProjectID, option.WithTokenSource(ts))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment