> For the complete documentation index, see [llms.txt](https://docs.alternativepayments.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alternativepayments.io/api-reference/oauth.md).

# OAuth

## Get OAuth2 access token

> OAuth2 client credentials flow endpoint. Generate a new access token using client credentials. The "client\_id" (username) and "client\_secret" (password) must be passed as Basic Auth credentials. Ex: Authorization: Basic Base64Encode(client\_id:client\_secret). The returned access token should be used as Bearer token for subsequent API calls: Authorization: Bearer {access\_token}

```json
{"openapi":"3.1.1","info":{"title":"Alternative Payments","version":"1.1.0"},"servers":[{"url":"http://public-api.alternativepayments.io"}],"security":[{"BasicAuth":[]}],"components":{"securitySchemes":{"BasicAuth":{"type":"http","scheme":"basic"}},"schemas":{"TokenResponse":{"description":"OAuth2 access token response structure containing the bearer token and expiration details","properties":{"access_token":{"description":"@Description The OAuth2 access token for API authentication - use as Bearer token in Authorization header\n@Example 580defdbe1d21e0001c67e5c2a0a6c98ba8b4a059dc5825388501574","type":"string"},"expires_in":{"description":"@Description Token expiration time in seconds from issuance\n@Example 3600","type":"integer"},"token_type":{"description":"@Description OAuth2 token type - always \"bearer\" for this implementation\n@Example bearer","type":"string"}},"type":"object"}}},"paths":{"/oauth/token":{"post":{"description":"OAuth2 client credentials flow endpoint. Generate a new access token using client credentials. The \"client_id\" (username) and \"client_secret\" (password) must be passed as Basic Auth credentials. Ex: Authorization: Basic Base64Encode(client_id:client_secret). The returned access token should be used as Bearer token for subsequent API calls: Authorization: Bearer {access_token}","operationId":"createOAuthToken","responses":{"200":{"description":"Successfully generated OAuth2 access token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TokenResponse"}}}},"403":{"description":"Invalid credentials","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object"}}}}},"summary":"Get OAuth2 access token","tags":["OAuth"],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","properties":{"grant_type":{"type":"string","description":"OAuth2 grant type - must be 'client_credentials'"}},"required":["grant_type"]}}}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.alternativepayments.io/api-reference/oauth.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
