> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.yunojuno.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.yunojuno.com/_mcp/server.

# Issue an OAuth access token

POST https://api.yunojuno.com/oauth/token
Content-Type: application/json

Exchange OAuth client credentials for a short-lived bearer token.

RFC 6749 defines the token request body as `application/x-www-form-urlencoded`. This endpoint also accepts `application/json` as an Auth0-compatible extension. Client credentials may be supplied using HTTP Basic authentication or in the request body.

This endpoint implements the OAuth 2.0 client credentials grant for the public API.

Reference: https://docs.yunojuno.com/client-api/authentication/oauth-token-create

## Request

### Body (application/json)

This endpoint expects an OAuthTokenRequest.

- `grant_type` (string, required)
- `client_id` (string, optional)
- `client_secret` (string, optional)
- `scope` (string, optional)

## Response

### 200

- `access_token` (string, required)
- `token_type` (string, required)
- `expires_in` (integer, required)

## Errors

### 400 Bad Request Error

Malformed token request.

- `error` (string, required)
- `error_description` (string, required)

### 401 Unauthorized Error

Client authentication failed.

- `error` (string, required)
- `error_description` (string, required)

## Examples

**Request**

```json
{
  "grant_type": "string"
}
```

**Response**

```json
{
  "access_token": "client_oa2_live_0123456789abcdef",
  "token_type": "Bearer",
  "expires_in": 3600
}
```

**SDK Code**

```python
import requests

url = "https://api.yunojuno.com/oauth/token"

payload = { "grant_type": "string" }
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.yunojuno.com/oauth/token';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"grant_type":"string"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.yunojuno.com/oauth/token"

	payload := strings.NewReader("{\n  \"grant_type\": \"string\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.yunojuno.com/oauth/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"grant_type\": \"string\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.yunojuno.com/oauth/token")
  .header("Content-Type", "application/json")
  .body("{\n  \"grant_type\": \"string\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.yunojuno.com/oauth/token', [
  'body' => '{
  "grant_type": "string"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.yunojuno.com/oauth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"grant_type\": \"string\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["grant_type": "string"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.yunojuno.com/oauth/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```