Skip to content
AffilStack Developers

Connect with AffilStack (OAuth)

Connect with AffilStack is standard OAuth 2.0 authorization code flow, with optional PKCE. The customer chooses what your app may access, and can disconnect it at any time.

1. Send the customer to AffilStack

From your Connect page, redirect the customer to:

Authorization URL
https://app.affilstack.com/oauth/authorize?response_type=code&client_id=afapp_…&redirect_uri=https%3A%2F%2Fyourapp.com%2Fcallback&scope=profile:read%20offers:read&state=RANDOM&code_challenge=…&code_challenge_method=S256
  • redirect_uri must exactly match one of your registered redirect URLs.
  • scope is a space-separated list of permissions from your listing. Leave it out to ask for all of them.
  • state is a random value you check when the customer comes back.
  • code_challenge (S256) is recommended. If you send one, send the matching code_verifier when exchanging the code.

If your app is paid, customers who haven't subscribed are asked to subscribe first and then return to the same screen.

2. Get the code back

When the customer clicks Allow, AffilStack redirects to your redirect_uri with ?code=…&state=…. If they cancel you get ?error=access_denied&state=…. Codes expire after 10 minutes and work once.

3. Exchange the code for tokens

Request
curl -X POST https://developer.affilstack.com/api/oauth/token \
  -d grant_type=authorization_code \
  -d code=THE_CODE \
  -d redirect_uri=https://yourapp.com/callback \
  -d code_verifier=THE_VERIFIER \
  -d client_id=afapp_… \
  -d client_secret=afsec_…
Response
{
    "access_token": "afat_…",
    "token_type": "Bearer",
    "expires_in": 3600,
    "refresh_token": "afrt_…",
    "scope": "profile:read offers:read"
}

You can also send the client ID and secret with HTTP Basic auth.

4. Refresh

Access tokens last 60 minutes. Get a new pair with grant_type=refresh_token and refresh_token=afrt_…. Each refresh token works once — store the new one. Refresh tokens expire after 90 days without use.

Revoking

POST token=… with your client credentials to https://developer.affilstack.com/api/oauth/revoke when a customer disconnects inside your app. When a customer removes your app in AffilStack, or their subscription ends, every token stops working.

Permissions

  • profile:read — See your name, email address and plan
  • offers:read — See your products and their research
  • offers:write — Add products to research
  • content:read — See the content you generate
  • crm:read — See your CRM contacts and lists
  • crm:write — Add and update CRM contacts
  • referrals:read — See your referral stats
  • earnings:read — Get notified when an earning is recorded