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

# OAuth · Approve authorization

POST https://oauth/authorize
Content-Type: application/json

Approves the pending OAuth authorization from the dashboard consent screen (Passport session endpoint).

`auth_token` is the single-use nonce the authorize redirect handed to the dashboard (`GET /oauth/authorize` → 302 to `{front}/oauth/authorize?auth_token=…`). It is bound to the web session: this endpoint needs the dashboard session cookie plus `X-XSRF-TOKEN` — a personal access token never authenticates it.

**Responses**:

* With `Accept: application/json` (what the SPA sends): **200** `{"redirect": url}` — the client callback carrying `code` and `state`. The SPA navigates there itself, top level, because a cross-origin XHR cannot follow a 302 to the client's origin (`ConvertsAuthorizationRedirectToJson`).
* Without it (plain navigation): **302** with the same URL in `Location`.
* Expired, unknown or reused `auth_token`: **403** — the nonce is single use, and the SPA renders its own invalid state for this status.

Host root, no `/api` prefix.

Reference: https://api.docs.modulards.com/modular-ds-public-api/o-auth-approve-authorization

## Authentication

- `Authorization` header (bearer token, required)

## Request

### Body (application/json)

- `auth_token` (string, required)

## Response

### 200

OK

- `redirect` (string, required)

## Examples

**Request**

```json
{
  "auth_token": "<auth_token from the consent screen URL>"
}
```

**Response**

```json
{
  "redirect": "https://claude.ai/api/mcp/auth_callback?code=def50200d4d3f39d823e0a3b3148f02b&state=client-state-123"
}
```

**SDK Code**

```python OAuth · Approve authorization_example
import requests

url = "https://https/oauth/authorize"

payload = { "auth_token": "<auth_token from the consent screen URL>" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript OAuth · Approve authorization_example
const url = 'https://https/oauth/authorize';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"auth_token":"<auth_token from the consent screen URL>"}'
};

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

```go OAuth · Approve authorization_example
package main

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

func main() {

	url := "https://https/oauth/authorize"

	payload := strings.NewReader("{\n  \"auth_token\": \"<auth_token from the consent screen URL>\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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 OAuth · Approve authorization_example
require 'uri'
require 'net/http'

url = URI("https://https/oauth/authorize")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"auth_token\": \"<auth_token from the consent screen URL>\"\n}"

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

```java OAuth · Approve authorization_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://https/oauth/authorize")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"auth_token\": \"<auth_token from the consent screen URL>\"\n}")
  .asString();
```

```php OAuth · Approve authorization_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://https/oauth/authorize', [
  'body' => '{
  "auth_token": "<auth_token from the consent screen URL>"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp OAuth · Approve authorization_example
using RestSharp;

var client = new RestClient("https://https/oauth/authorize");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"auth_token\": \"<auth_token from the consent screen URL>\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift OAuth · Approve authorization_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["auth_token": "<auth_token from the consent screen URL>"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://https/oauth/authorize")! 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()
```