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:
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_urimust exactly match one of your registered redirect URLs.scopeis a space-separated list of permissions from your listing. Leave it out to ask for all of them.stateis a random value you check when the customer comes back.code_challenge(S256) is recommended. If you send one, send the matchingcode_verifierwhen 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
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_…
{
"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 planoffers:read— See your products and their researchoffers:write— Add products to researchcontent:read— See the content you generatecrm:read— See your CRM contacts and listscrm:write— Add and update CRM contactsreferrals:read— See your referral statsearnings:read— Get notified when an earning is recorded