
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
github.com/hentaiOS-Infrastructure/patreon-go-wrapper
Advanced tools
patreon-go-wrapper is a Go client library for accessing the Patreon API V2.
Forked from patreon-go which has a great implementation for Patreon API V1
The patreon-go-wrapper package may be installed by running:
go get github.com/austinbspencer/patreon-go-wrapper
or
import "github.com/austinbspencer/patreon-go-wrapper"
import (
"fmt"
"github.com/austinbspencer/patreon-go-wrapper"
)
func main() {
client := patreon.NewClient(nil)
user, err := client.FetchIdentity()
if err != nil {
// handle the error
}
fmt.Println(user.Data.Id)
}
The patreon-go-wrapper library does not directly handle authentication. Instead, when creating a new client, pass an http.Client that can handle authentication for you, most likely you will need oauth2 package.
Here is an example with static token:
import (
"github.com/austinbspencer/patreon-go-wrapper"
"golang.org/x/oauth2"
)
func NewPatreonClient(ctx context.Context, token string) *patreon.Client {
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
tc := oauth2.NewClient(ctx, ts)
client := patreon.NewClient(tc)
return client
}
Automatically refresh token:
Check the available scopes in the Patreon Docs
func NewPatreonClient() (*patreon.Client, error) {
config := oauth2.Config{
ClientID: "<client_id>",
ClientSecret: "<client_secret>",
Endpoint: oauth2.Endpoint{
AuthURL: AuthorizationURL,
TokenURL: AccessTokenURL,
},
Scopes: patreon.AllScopes,
}
token := oauth2.Token{
AccessToken: "<current_access_token>",
RefreshToken: "<current_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 := NewClient(tc)
_, err := client.FetchIdentity()
return client, err
}
package main
import (
"context"
"fmt"
"os"
"time"
"github.com/austinbspencer/patreon-go-wrapper"
_ "github.com/joho/godotenv/autoload"
"golang.org/x/oauth2"
)
func main() {
patreonConfig := oauth2.Config{
ClientID: os.Getenv("PATREON_CLIENT_ID"),
ClientSecret: os.Getenv("PATREON_CLIENT_SECRET"),
Endpoint: oauth2.Endpoint{
AuthURL: patreon.AuthorizationURL,
TokenURL: patreon.AccessTokenURL,
},
Scopes: patreon.AllScopes,
}
token := oauth2.Token{
AccessToken: os.Getenv("PATREON_ACCESS_TOKEN"),
RefreshToken: os.Getenv("PATREON_REFRESH_TOKEN"),
// Must be non-nil, otherwise token will not be expired
Expiry: time.Now().Add(2 * time.Hour),
}
tc := patreonConfig.Client(context.Background(), &token)
client := patreon.NewClient(tc)
fieldOpts := patreon.WithFields("user", patreon.UserFields...)
campOpts := patreon.WithFields("campaign", patreon.CampaignFields...)
includeOpts := patreon.WithIncludes("campaign")
user, err := client.FetchIdentity(fieldOpts, campOpts, includeOpts)
if err != nil {
panic(err)
}
for _, item := range user.Included.Items {
res, ok := item.(*patreon.Campaign)
if !ok {
fmt.Println("Not oke!")
continue
}
fmt.Println(res.Attributes.Summary)
}
}
FAQs
Unknown package
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.