# Password flow

The OAuth 2.0 **Resource Owner Password Credentials Grant** ([RFC 6749 §4.3](https://tools.ietf.org/html/rfc6749#section-4.3)), `grant_type: password`, exchanges a Salaxy username and password for an access token.

**Development only:**
Enabled in the **test environments** only. It can be used in production only after manual registration — [contact Salaxy](https://www.salaxy.com). For production integrations, use the [impersonation flow](https://code.salaxy.com/security/impersonation.md).

Examples use `test-*` hosts — see [Environments](https://code.salaxy.com/get-started/environments.md) for demo and production.

## Request

`POST /oauth2/token`

| Parameter | Description |
|---|---|
| `grant_type` | `password` |
| `username` | Your Salaxy account username |
| `password` | Your Salaxy account password |

```http
POST https://test-secure.salaxy.com/oauth2/token
Content-Type: application/json

{
  "grant_type": "password",
  "username": "john.doe@example.com",
  "password": "MySecurePassword"
}
```

## Response

```json
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "bearer"
}
```

Send the `access_token` as a Bearer token on each API call — see [Tokens](https://code.salaxy.com/security/rest-authentication.md#tokens). The response has no `expires_in`: the token lasts 48 hours.

A wrong username or password returns HTTP 400:

```json
{ "error": "access_denied", "error_description": "Incorrect username or password." }
```

A runnable version, where you type your test account's email and password: [API authentication on the current site](https://code.salaxy.com/docs/api-authentication).
