> This page is for version v1.
> For other versions, use one of these documentation indexes:
> - v2 (default): https://autodesk-poc.ferndocs.com/v2/llms.txt
> - v1: https://autodesk-poc.ferndocs.com/v1/llms.txt

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

# Get a 2-legged access token

POST https://developer.api.autodesk.com/authentication/v2/token
Content-Type: application/x-www-form-urlencoded

Exchanges your app's client ID and client secret for a 2-legged access token.
Client authentication may be sent either in the body (below) or as a
`Authorization: Basic base64(client_id:client_secret)` header, but not both —
sending both returns `400`.


Reference: https://autodesk-poc.ferndocs.com/acc-admin/authentication/get-token

## Request

### Body (application/x-www-form-urlencoded)

This endpoint expects an object.

- `grant_type` (enum, required, default: client_credentials) — Must be `client_credentials` for a 2-legged token.
  - Allowed values: `client_credentials`
- `client_id` (string, required) — The client ID of your APS app.
- `client_secret` (string, required) — The client secret of your APS app.
- `scope` (string, optional) — Space-separated list of scopes the token should carry, for example `account:read account:write`.

## Response

### 200

An access token.

- `access_token` (string, required) — The access token to send in the `Authorization` header.
- `token_type` (string, required) — Always `Bearer`.
- `expires_in` (integer, required) — Lifetime of the access token, in seconds.

## Errors

### 400 Bad Request Error

The request was malformed, or client authentication was sent in both the header and the body.

- `any`

### 401 Unauthorized Error

The client ID or client secret is invalid.

- `any`

## Examples

**Request**

```json
{
  "grant_type": "client_credentials",
  "client_id": "string",
  "client_secret": "string"
}
```

**Response**

```json
{
  "access_token": "string",
  "token_type": "string",
  "expires_in": 1
}
```

**SDK Code**

```python
import requests

url = "https://developer.api.autodesk.com/authentication/v2/token"

payload = ""
headers = {"Content-Type": "application/x-www-form-urlencoded"}

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

print(response.json())
```

```javascript
const url = 'https://developer.api.autodesk.com/authentication/v2/token';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  body: new URLSearchParams('')
};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://developer.api.autodesk.com/authentication/v2/token"

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

	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

	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://developer.api.autodesk.com/authentication/v2/token")

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

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/x-www-form-urlencoded'

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://developer.api.autodesk.com/authentication/v2/token")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://developer.api.autodesk.com/authentication/v2/token', [
  'form_params' => null,
  'headers' => [
    'Content-Type' => 'application/x-www-form-urlencoded',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://developer.api.autodesk.com/authentication/v2/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/x-www-form-urlencoded"]

let request = NSMutableURLRequest(url: NSURL(string: "https://developer.api.autodesk.com/authentication/v2/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```