{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"3. Generate an access token","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"3-generate-an-access-token","__idx":0},"children":["3. Generate an access token"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the client credentials generated in ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/integration/api/api-client-creds"},"children":["step 2"]}," to generate an access token. This token must be used in all API requests made to the Spotnana platform."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Generate an access token using the endpoint below:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["POST /v2/auth/oauth2-token"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Request:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl --location 'https://api-ext-sboxmeta.partners.spotnana.com/v2/auth/oauth2-token' \\\n  --header 'Content-Type: application/x-www-form-urlencoded' \\\n  --data-urlencode 'client_id=<your-client-id>' \\\n  --data-urlencode 'client_secret=<your-client-secret>' \\\n  --data-urlencode 'grant_type=client_credentials'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"access_token\": \"<access_token>\",\n  \"expires_in\": 3600,\n  \"token_type\": \"Bearer\"\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The bearer token generated using this API must be used in the authorization header for all API calls made to the Spotnana platform."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"best-practices","__idx":1},"children":["Best practices"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Build a mechanism to securely cache the access token in your system and reuse it until it expires."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Do not request new tokens for each API call as the token generation API is rate limited. Generate a new token only when the current token has expired or is about to be expired."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://en.wikipedia.org/wiki/Exponential_backoff"},"children":["exponential backoff"]}," to retry when a ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"/spotnana/error_handling#429---rate-limit-exceeded"},"children":["429 error"]}," is encountered (i.e., rate limit exceeded)."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"upon-completion-of-this-step-youll-have","__idx":2},"children":["Upon completion of this step, you'll have:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The access token needed to make API calls to the Spotnana platform."]}]}]},"headings":[{"value":"3. Generate an access token","id":"3-generate-an-access-token","depth":1},{"value":"Best practices","id":"best-practices","depth":2},{"value":"Upon completion of this step, you'll have:","id":"upon-completion-of-this-step-youll-have","depth":4}],"frontmatter":{"seo":{"title":"3. Generate an access token"}},"lastModified":"2026-04-22T17:33:23.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/integration/api/api-access-token","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}