# Create an OAuth token POST https://api.moveworks.ai/oauth/v1/token Content-Type: application/json Generate an Access Token using OAuth 2.0 Client Credentials for authentication in subsequent API calls to other endpoints. See [Credentials Management - OAuth 2.0 Client](/reference/get-api-keys) for more info. Reference: https://docs.moveworks.com/api-reference/events-api/authentication/create-o-auth-token ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Create an OAuth token version: endpoint_authentication.createOAuthToken paths: /oauth/v1/token: post: operationId: create-o-auth-token summary: Create an OAuth token description: > Generate an Access Token using OAuth 2.0 Client Credentials for authentication in subsequent API calls to other endpoints. See [Credentials Management - OAuth 2.0 Client](/reference/get-api-keys) for more info. tags: - - subpackage_authentication parameters: [] responses: '200': description: Token created content: application/json: schema: $ref: '#/components/schemas/OauthTokenGenerated' '400': description: Bad Request content: {} '401': description: Unauthenticated content: {} '429': description: Rate Limit Exceeded content: {} '500': description: Internal Server Error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/OauthTokenRequest' components: schemas: OauthTokenRequest: type: object properties: client_id: type: string description: >- The client's unique identifier; acquired during the creation of credentials in Events Workspace. client_secret: type: string description: >- The client's secret key; acquired during the creation of credentials in Events Workspace. grant_type: type: string description: >- Specifies the type of grant being used for the token request. This should be set to \"client_credentials\". required: - client_id - client_secret - grant_type OauthTokenGeneratedData: type: object properties: access_token: type: string expires_in: type: integer token_type: type: string OauthTokenGenerated: type: object properties: data: $ref: '#/components/schemas/OauthTokenGeneratedData' ``` ## SDK Code Examples ```python import requests url = "https://api.moveworks.ai/oauth/v1/token" payload = { "client_id": "15d8db87-9a06-4d5d-8e22-0b4e6c6c30a7", "client_secret": "mws_ygD73mHVN9tgrScyFQZ8HIQRq9fNniNtuSuXMlt4wqu3E9Jit8wOoUVWLWblyUVDtW6lMz2QS6GTZqupMFD7RaiS8BucVVDH766b", "grant_type": "client_credentials" } headers = {"Content-Type": "application/json"} response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.moveworks.ai/oauth/v1/token'; const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"client_id":"15d8db87-9a06-4d5d-8e22-0b4e6c6c30a7","client_secret":"mws_ygD73mHVN9tgrScyFQZ8HIQRq9fNniNtuSuXMlt4wqu3E9Jit8wOoUVWLWblyUVDtW6lMz2QS6GTZqupMFD7RaiS8BucVVDH766b","grant_type":"client_credentials"}' }; 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.moveworks.ai/oauth/v1/token" payload := strings.NewReader("{\n \"client_id\": \"15d8db87-9a06-4d5d-8e22-0b4e6c6c30a7\",\n \"client_secret\": \"mws_ygD73mHVN9tgrScyFQZ8HIQRq9fNniNtuSuXMlt4wqu3E9Jit8wOoUVWLWblyUVDtW6lMz2QS6GTZqupMFD7RaiS8BucVVDH766b\",\n \"grant_type\": \"client_credentials\"\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.moveworks.ai/oauth/v1/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 \"client_id\": \"15d8db87-9a06-4d5d-8e22-0b4e6c6c30a7\",\n \"client_secret\": \"mws_ygD73mHVN9tgrScyFQZ8HIQRq9fNniNtuSuXMlt4wqu3E9Jit8wOoUVWLWblyUVDtW6lMz2QS6GTZqupMFD7RaiS8BucVVDH766b\",\n \"grant_type\": \"client_credentials\"\n}" 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://api.moveworks.ai/oauth/v1/token") .header("Content-Type", "application/json") .body("{\n \"client_id\": \"15d8db87-9a06-4d5d-8e22-0b4e6c6c30a7\",\n \"client_secret\": \"mws_ygD73mHVN9tgrScyFQZ8HIQRq9fNniNtuSuXMlt4wqu3E9Jit8wOoUVWLWblyUVDtW6lMz2QS6GTZqupMFD7RaiS8BucVVDH766b\",\n \"grant_type\": \"client_credentials\"\n}") .asString(); ``` ```php request('POST', 'https://api.moveworks.ai/oauth/v1/token', [ 'body' => '{ "client_id": "15d8db87-9a06-4d5d-8e22-0b4e6c6c30a7", "client_secret": "mws_ygD73mHVN9tgrScyFQZ8HIQRq9fNniNtuSuXMlt4wqu3E9Jit8wOoUVWLWblyUVDtW6lMz2QS6GTZqupMFD7RaiS8BucVVDH766b", "grant_type": "client_credentials" }', 'headers' => [ 'Content-Type' => 'application/json', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.moveworks.ai/oauth/v1/token"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"client_id\": \"15d8db87-9a06-4d5d-8e22-0b4e6c6c30a7\",\n \"client_secret\": \"mws_ygD73mHVN9tgrScyFQZ8HIQRq9fNniNtuSuXMlt4wqu3E9Jit8wOoUVWLWblyUVDtW6lMz2QS6GTZqupMFD7RaiS8BucVVDH766b\",\n \"grant_type\": \"client_credentials\"\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = ["Content-Type": "application/json"] let parameters = [ "client_id": "15d8db87-9a06-4d5d-8e22-0b4e6c6c30a7", "client_secret": "mws_ygD73mHVN9tgrScyFQZ8HIQRq9fNniNtuSuXMlt4wqu3E9Jit8wOoUVWLWblyUVDtW6lMz2QS6GTZqupMFD7RaiS8BucVVDH766b", "grant_type": "client_credentials" ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.moveworks.ai/oauth/v1/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() ```