Skip to content

Instantly share code, notes, and snippets.

@Gattermeier
Last active October 11, 2023 15:47
Show Gist options
  • Save Gattermeier/71b8de83d2043a81f7b98e439ed934c1 to your computer and use it in GitHub Desktop.
Save Gattermeier/71b8de83d2043a81f7b98e439ed934c1 to your computer and use it in GitHub Desktop.
go implementation to get access token for oak from scoop auth
// https://github.com/nytimes/nodetools/blob/main/scoop/auth.js#L15C1-L37C3
func getToken() (string, error) {
conf := &oauth2.Config{
ClientID: "interactive",
Endpoint: oauth2.Endpoint{
TokenURL: tokenURL,
AuthURL: authURL,
},
}
token, err := conf.PasswordCredentialsToken(context.Background(), username, password)
if err != nil {
return "", err
}
return token.AccessToken, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment