Skip to main content
Use Go 1.23 or later on your backend (your app’s server). Get an access token with the profile:read permission and a linked account ID from Connect an account.

Install

Use the HTTP quickstart until the SDK release candidate is published. In your Go module, run:

Read the current profile

Set OFAUTH_ACCESS_TOKEN and OFAUTH_LINKED_ACCOUNT_ID in your server’s environment. Save this as main.go and run go run main.go:
The SDK sends the access token and linked account header for you.

Check the result

The program prints the account’s profile as JSON. Check its id, username, and name. Missing values stay null. This request does not change the account. If the API returns an error, use errors.As to read it as *ofauth.APIError. Its Code, RecoveryAction, and RequestID help you choose the next step. See Handle failed requests. Check whether a message or post was created before repeating a request whose result you did not receive.

Use the client in your application

Use Iterate() to read all pages of a list. Inside main, list the accounts shared through this authorization:
Use client.WithLinkedAccount(accountID) to select another account shared through the same authorization. Pass a context with a deadline or cancellation when your app needs to stop a request.

Connect customers and renew access

Use the SDK’s OAuth helper or a standard confidential OAuth client with the authorization-code contract. Persist callback state and PKCE against the initiating application user and browser session, with expiry and single use. Validate the issuer and exact redirect URI before exchange. Your auth framework or application owns token persistence and refresh. Supply its current access token to the resource client. Use the returned expires_in, and refresh through the form-encoded token endpoint. Code exchanges always return a refresh token. The refresh token is stable and bound to the authenticated client. Independent instances can refresh concurrently; retry a lost refresh response with the same token. No database refresh lock, attempt marker, or replay journal is required. Use ordinary conditional writes so an earlier refresh cannot replace a registration the customer has changed or disconnected. Keep client and environment in each application’s customer storage key. Discover all granted accounts, then persist an explicit account choice. An account ID does not choose authority or billing. Revoking a refresh token ends that credential and its access tokens. Ending the authorization ends all its credentials. A provider session error requires account reconnect, which does not renew OAuth or replay a write. See the Express source example for the complete backend journey.