Created
March 20, 2020 17:52
-
-
Save ernestoalejo/5c9ecbd3212ae5c7af6cf03c8ef037d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
log "github.com/sirupsen/logrus" | |
"libs.altipla.consulting/errors" | |
"golang.org/x/oauth2/google" | |
) | |
func main() { | |
if err := run(); err != nil { | |
log.Fatal(errors.Stack(err)) | |
} | |
} | |
const foo = ` | |
{ | |
... | |
} | |
` | |
func run() error { | |
ts, err := google.JWTAccessTokenSourceFromJSON([]byte(foo), "http://vault/my-iam-role") | |
if err != nil { | |
return errors.Trace(err) | |
} | |
token, err := ts.Token() | |
if err != nil { | |
return errors.Trace(err) | |
} | |
log.Println(token) | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment