> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.itential.com/itential-cloud/api-reference/oauth/machine-authentication/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server. # Retrieve a JWT from a client's credentials POST https://example.itential.io/oauth/token Content-Type: application/x-www-form-urlencoded Retrieves a JWT from a client's credentials. Reference: https://docs.itential.com/itential-cloud/api-reference/oauth/machine-authentication ## Request ### Body (application/x-www-form-urlencoded) This endpoint expects an object. - `client_id` (string, optional) — String representation of a MongoDB ObjectId - `client_secret` (string, optional) — Uuid representation of client secret - `grant_type` (enum, optional) - Allowed values: `client_credentials` ## Response ### 200 result - `access_token` (string, optional) — The JWT providing the user access to IAP - `token_type` (enum, optional) — The type of token provided - Allowed values: `bearer` - `expires_in` (enum, optional) — The amount of time until the JWT expires - Allowed values: `3600` ## Errors ### 500 Internal Server Error Error response from API - `any` ## Examples **Request** ```json {} ``` **Response** ```json { "access_token": "string", "token_type": "bearer", "expires_in": 3600 } ``` **SDK Code** ```python import requests url = "https://example.itential.io/oauth/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://example.itential.io/oauth/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://example.itential.io/oauth/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://example.itential.io/oauth/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 response = Unirest.post("https://example.itential.io/oauth/token") .header("Content-Type", "application/x-www-form-urlencoded") .asString(); ``` ```php request('POST', 'https://example.itential.io/oauth/token', [ 'form_params' => null, 'headers' => [ 'Content-Type' => 'application/x-www-form-urlencoded', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://example.itential.io/oauth/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://example.itential.io/oauth/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() ```