Categorygithub.com/trichner/oauthflows
repositorypackage
0.0.0-20240121151932-a3a7c0084382
Repository: https://github.com/trichner/oauthflows.git
Documentation: pkg.go.dev

# README

OAuth2 Browser Flows for CLIs

Obtain OAuth2 tokens by sending users through the OAuth2 flow in a local webserver.

scopes := []string{"openid", "profile"}
client, err := oauthflows.NewClient(oauthflows.WithClientSecretsFile(clientSecretsPath, scopes), oauthflows.WithFileTokenStore())
if err != nil {
log.Fatal(err)
}

res, err := client.Get("https://www.googleapis.com/oauth2/v1/userinfo?alt=json")
defer res.Body.Close()
if err != nil {
log.Fatal(err)
}

data, err := io.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}

fmt.Println(string(data))