OAuth Clients
OAuth clients represent third-party applications that access the Zendesk API on behalf of users.
JSON format
OAuth Clients are represented as JSON objects with the following properties:
| Name | Type | Read-only | Mandatory | Description |
|---|---|---|---|---|
| company | string | false | false | The company name displayed when users are asked to grant access to your application. |
| created_at | string | true | false | The time the client was created |
| description | string | false | false | A short description of your client that is displayed to users when they are considering approving access to your application |
| global | boolean | true | false | Whether this client is globally accessible. See Set up a global OAuth client |
| id | integer | true | false | Automatically assigned upon creation |
| identifier | string | false | true | The unique identifier for this client |
| kind | string | false | false | Either "public" or "confidential". Specifies whether the OAuth client operates in a public environment where credentials cannot be securely stored, or on secure servers that can safely store credentials. See Client types |
| logo_url | string | true | false | The API logo url of this record |
| name | string | false | true | The name of this client |
| redirect_uri | array | false | false | An array of the valid redirect URIs for this client |
| scope | string | false | false | A space-separated list of allowed scopes for this client. Defines the maximum set of scopes the client is permitted to request during the OAuth authorization flow. When set, the client can only request scopes included in this list. If a client requests a scope not included in its allowed scopes, the request fails with a 400 Bad Request response and an invalid_scope error. If not set, no scope restrictions are applied. For the full list of valid scope values, see Scopes. |
| secret | string | true | false | The client secret. Generated automatically on creation and returned in full only at that time |
| updated_at | string | true | false | The time of the last update of the client |
| url | string | true | false | The API url of this record |
| user_id | integer | false | true | The id of the admin who created the client |
Example
{"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Test Client","id": 1,"identifier": "test_client","name": "My Test Client","redirect_uri": ["https://example.com/callback"],"scope": "tickets:read users:read","secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/1","user_id": 29}
List Clients
GET /api/v2/oauth/clients
Pagination
- Cursor pagination (recommended)
- Offset pagination
See Pagination.
Returns a maximum of 100 records per page.
Allowed For
- Admins
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| page | object | Query | false | Cursor-based pagination parameters (JSON:API style). Supports nested parameters: - page[size] - Number of records per page (default varies by endpoint, typically 100) - page[after] - Cursor token to fetch records after this position - page[before] - Cursor token to fetch records before this position Example: ?page[size]=50&page[after]=eyJvIjoiaWQiLCJ2IjoiYVFFPSJ9 |
| sort | string | Query | false | Field to sort results by. Prefix with - for descending order. When used with cursor pagination, this determines the cursor ordering. Example: ?sort=name or ?sort=-created_at |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/oauth/clients \-H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/oauth/clients?page=&sort=name"method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://example.zendesk.com/api/v2/oauth/clients").newBuilder().addQueryParameter("page", "").addQueryParameter("sort", "name");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://example.zendesk.com/api/v2/oauth/clients',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},params: {'page': '','sort': 'name',},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/oauth/clients?page=&sort=name"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("GET",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/oauth/clients")uri.query = URI.encode_www_form("page": "", "sort": "name")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"clients": [{"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Test Client","id": 223443,"identifier": "test_client","name": "Stats Widget","redirect_uri": ["https://example.com/callback"],"secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/223443","user_id": 29},{"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Mobile Client","id": 8678530,"identifier": "mobile_client","name": "Zendesk Mobile","redirect_uri": ["https://example.com/callback"],"secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/8678530","user_id": 29}]}
Show Client
GET /api/v2/oauth/clients/{oauth_client_id}
Allowed for
- Admins
- Agents with the Manage APIs permission
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| oauth_client_id | integer | Path | true | The ID of the OAuth client |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/oauth/clients/{oauth_client_id} \-H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/oauth/clients/223443"method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://example.zendesk.com/api/v2/oauth/clients/223443").newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://example.zendesk.com/api/v2/oauth/clients/223443',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/oauth/clients/223443"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("GET",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/oauth/clients/223443")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"client": {"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Test Client","id": 223443,"identifier": "test_client","name": "Test Client","redirect_uri": ["https://example.com/callback"],"secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/223443","user_id": 29}}
Create Client
POST /api/v2/oauth/clients
Allowed For
- Admins
- Agents with the Manage APIs permission
Allowed scopes
You can optionally set a scope property on the client to restrict which scopes it is
permitted to request during the OAuth authorization flow. The value is a space-separated
string of scope values. When set, any token request using this client must only include
scopes from this list. If a client requests a scope not included in its allowed scopes,
the request fails with a 400 Bad Request response and an invalid_scope error. If
scope is omitted, no scope restrictions are applied to the client.
For the full list of valid scope values, see Scopes.
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/oauth/clients \-X POST -H "Content-Type: application/json" \-d '{"client": {"name": "Test Client", "identifier": "unique_id", "kind": "confidential", "scope": "tickets:read users:read"}}'-H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/oauth/clients"method := "POST"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://example.zendesk.com/api/v2/oauth/clients").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("POST", body).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'POST',url: 'https://example.zendesk.com/api/v2/oauth/clients',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/oauth/clients"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("POST",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/oauth/clients")request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
201 Created
// Status 201 Created{"client": {"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Test Client","id": 223443,"identifier": "test_client","name": "Test Client","redirect_uri": ["https://example.com/callback"],"secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/223443","user_id": 29}}
Update Client
PUT /api/v2/oauth/clients/{oauth_client_id}
Allowed for
- Admins
- Agents with the Manage APIs permission
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| oauth_client_id | integer | Path | true | The ID of the OAuth client |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/oauth/clients/{oauth_client_id} \-X PUT -H "Content-Type: application/json" \-d '{"client": {"name": "My New OAuth2 Client"}}'-H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/oauth/clients/223443"method := "PUT"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://example.zendesk.com/api/v2/oauth/clients/223443").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("PUT", body).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'PUT',url: 'https://example.zendesk.com/api/v2/oauth/clients/223443',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/oauth/clients/223443"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("PUT",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/oauth/clients/223443")request = Net::HTTP::Put.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"client": {"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Test Client","id": 223443,"identifier": "test_client","name": "My New OAuth2 Client","redirect_uri": ["https://example.com/callback"],"secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/223443","user_id": 29}}
Delete Client
DELETE /api/v2/oauth/clients/{oauth_client_id}
Allowed for
- Admins
- Agents with the Manage APIs permission
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| oauth_client_id | integer | Path | true | The ID of the OAuth client |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/oauth/clients/{oauth_client_id} \-X DELETE -H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/oauth/clients/223443"method := "DELETE"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://example.zendesk.com/api/v2/oauth/clients/223443").newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("DELETE", null).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'DELETE',url: 'https://example.zendesk.com/api/v2/oauth/clients/223443',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/oauth/clients/223443"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("DELETE",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/oauth/clients/223443")request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
204 No Content
// Status 204 No Contentnull
Generate Secret
PUT /api/v2/oauth/clients/{oauth_client_id}/generate_secret
Allowed for
- Admins
- Agents with the Manage APIs permission
Parameters
| Name | Type | In | Required | Description |
|---|---|---|---|---|
| oauth_client_id | integer | Path | true | The ID of the OAuth client |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/oauth/clients/{oauth_client_id}/generate_secret \-X PUT -H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/oauth/clients/223443/generate_secret"method := "PUT"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://example.zendesk.com/api/v2/oauth/clients/223443/generate_secret").newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),"""""");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("PUT", body).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'PUT',url: 'https://example.zendesk.com/api/v2/oauth/clients/223443/generate_secret',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/oauth/clients/223443/generate_secret"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("PUT",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/oauth/clients/223443/generate_secret")request = Net::HTTP::Put.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"client": {"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Test Client","id": 223443,"identifier": "test_client","name": "Test Client","redirect_uri": ["https://example.com/callback"],"secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/223443","user_id": 29}}
List Current User's Clients
GET /api/v2/users/me/oauth/clients
Returns the OAuth clients owned by the current user.
Pagination
- Cursor pagination (recommended)
- Offset pagination
See Pagination.
Returns a maximum of 100 records per page.
Allowed For
- Admins
- Agents with the Manage APIs permission
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/users/me/oauth/clients \-H "Authorization: Bearer {access_token}"
Go
import ("fmt""io""net/http")func main() {url := "https://example.zendesk.com/api/v2/users/me/oauth/clients"method := "GET"req, err := http.NewRequest(method, url, nil)if err != nil {fmt.Println(err)return}req.Header.Add("Content-Type", "application/json")req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "{email_address}/token:{api_token}"client := &http.Client {}res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := io.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
Java
import com.squareup.okhttp.*;OkHttpClient client = new OkHttpClient();HttpUrl.Builder urlBuilder = HttpUrl.parse("https://example.zendesk.com/api/v2/users/me/oauth/clients").newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());Request request = new Request.Builder().url(urlBuilder.build()).method("GET", null).addHeader("Content-Type", "application/json").addHeader("Authorization", basicAuth).build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var config = {method: 'GET',url: 'https://example.zendesk.com/api/v2/users/me/oauth/clients',headers: {'Content-Type': 'application/json','Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"},};axios(config).then(function (response) {console.log(JSON.stringify(response.data));}).catch(function (error) {console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuthurl = "https://example.zendesk.com/api/v2/users/me/oauth/clients"headers = {"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)response = requests.request("GET",url,auth=auth,headers=headers)print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://example.zendesk.com/api/v2/users/me/oauth/clients")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|http.request(request)end
Example response(s)
200 OK
// Status 200 OK{"clients": [{"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Test Client","id": 223443,"identifier": "test_client","name": "Stats Widget","redirect_uri": ["https://example.com/callback"],"secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/223443","user_id": 29},{"company": "Zendesk","created_at": "2009-05-13T00:07:08Z","description": "Zendesk Mobile Client","id": 8678530,"identifier": "mobile_client","name": "Zendesk Mobile","redirect_uri": ["https://example.com/callback"],"secret": "af3t24tfj34h43s...","updated_at": "2011-07-22T00:11:12Z","url": "https://example.zendesk.com/api/v2/clients/8678530","user_id": 29}]}