panic: Get "https://api.patreon.com/oauth2/api/current_user": oauth2: cannot fetch token: 401 Unauthorized
Response: {"error": "invalid_grant"}
I did modify the NewPatreonClient() in the README slightly because it was throwing errors due to missing a return and NewClient method not referencing the package. Here's my code:
func NewPatreonClient() (*patreon.Client, error) {
config := oauth2.Config{
ClientID: os.Getenv("PATREON_CLIENT_ID"),
ClientSecret: os.Getenv("PATREON_CLIENT_SECRET"),
Endpoint: oauth2.Endpoint{
AuthURL: AUTHORIZATION_URL,
TokenURL: ACCESS_TOKEN_URL,
},
Scopes: []string{"users", "pledges-to-me", "my-campaign"},
}
token := oauth2.Token{
AccessToken: os.Getenv("PATREON_CREATOR_ACCESS_TOKEN"),
RefreshToken: os.Getenv("PATREON_CREATOR_REFRESH_TOKEN"),
// Must be non-nil, otherwise token will not be expired
Expiry: time.Now().Add(-24 * time.Hour),
}
tc := config.Client(context.Background(), &token)
client := patreon.NewClient(tc)
user, err := client.FetchUser()
if err != nil {
panic(err)
}
fmt.Printf("%v\n", user)
return client, nil
}
I'm attempting to call
NewPatreonClient()for as defined in the README and receiving this error:I did modify the NewPatreonClient() in the README slightly because it was throwing errors due to missing a return and
NewClientmethod not referencing the package. Here's my code:I'm using
patreon-go.v1