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

# Post Oauth Token

We recommend this endpoint for authentication.

* SameSystem uses OAuth 2.0 protocol for authorization and it supports **Resource Owner Password Credentical** and **Refresh token** grant types.
* Password grant type is used to get access and refresh tokens. The access token is expiring in 1 hour, and the refresh token expires in 6 month. The tokens you will received are **bearer**.
* Every call you make will require you to have the access token in the Authorisation header, so add Bearer and then the access token afterwards.
* You can get the access and refresh tokens with the API user and password received from SameSystem, and setting the grant\_type to **password**.
* After the access token expires, you can use the Refresh token grant type get a new access token.
* To swap the refresh token for a new access token, use the same endpoint, but add this in the request body instead:

```json
{
    "refresh_token": "kfjdfhjdlkjfkjflhkjasdjhfjdhffjkhdfjkdhfjkhdfjkhf",
    "grant_type": "refresh_token"
}
```

````json
{"openapi":"3.0.0","info":{"title":"SameSystem API V1","version":"1.1.3"},"servers":[{"url":"https://api.samesystem.com/api/v1/","description":""}],"paths":{"/{clientToken}/oauth/token":{"post":{"tags":["Authentication"],"summary":"","description":"We recommend this endpoint for authentication.\n- SameSystem uses OAuth 2.0 protocol for authorization and it supports **Resource Owner Password Credentical** and **Refresh token** grant types.\n\n- Password grant type is used to get access and refresh tokens. The access token is expiring in 1 hour, and the refresh token expires in 6 month. The tokens you will received are **bearer**.\n\n- Every call you make will require you to have the access token in the Authorisation header, so add Bearer and then the access token afterwards.\n\n- You can get the access and refresh tokens with the API user and password received from SameSystem, and setting the grant_type to **password**.\n\n- After the access token expires, you can use the Refresh token grant type get a new access token.\n\n- To swap the refresh token for a new access token, use the same endpoint, but add this in the request body instead:\n```json\n{\n    \"refresh_token\": \"kfjdfhjdlkjfkjflhkjasdjhfjdhffjkhdfjkdhfjkhdfjkhf\",\n    \"grant_type\": \"refresh_token\"\n}\n```","operationId":"post-oauth-token","parameters":[{"name":"clientToken","in":"path","description":"Token in a form of \"c\\<clientId\\>\".","required":true,"schema":{"type":"string"}}],"requestBody":{"description":"","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AUTH_PROVIDER_INPUT"}}}},"responses":{"200":{"description":"Successful","content":{"application/json":{"schema":{"type":"object","properties":{"access_token":{"type":"string"},"expires_in":{"type":"number","default":3600},"refresh_token":{"type":"string"},"token_type":{"type":"string"}}}}}},"400":{"description":"Incorrect login.\nIn case of wrong credentials, incorrect refresh token, or wrong grant_type, you will receive one of the error messages below.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string"}}}}}}}}}},"components":{"schemas":{"AUTH_PROVIDER_INPUT":{"title":"AUTH_PROVIDER_INPUT","required":["grant_type","password","username"],"type":"object","properties":{"username":{"type":"string"},"password":{"type":"string"},"grant_type":{"type":"string","default":"password"}}}}}}
````


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.samesystem.dev/api-v1-reference/authentication/post-oauth-token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
