{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-products/rest/guides/sidebars.yaml","oas-products/rest/reference/authorization/client-credentials-sample.yaml":"oas-products/rest/reference/authorization/client-credentials-sample.yaml"},"props":{"metadata":{"markdoc":{"tagList":["partial","json-schema","openapi-code-sample","openapi-response-sample"]},"type":"markdown"},"seo":{"title":"Client Credentials Flow","description":"Embed DailyPay On Demand Pay into your applications with our APIs and SDKs.","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":["openapi"],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"client-credentials-flow","__idx":0},"children":["Client Credentials Flow"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The purpose of following the OAuth2 flow is to help you retrieve an ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["access token"]}]}," using your application's private client credentials."," ","Complete details of the specification are available in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.rfc-editor.org/rfc/rfc6749#section-4.4"},"children":["RFC 6749 section 4.4"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Send the following parameters www-form-encoded in the request body to the token endpoint:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Environment"},"children":["Environment"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Token Endpoint"},"children":["Token Endpoint"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Production"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://auth.dailypay.com/oauth2/token"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["UAT"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["https://auth.uat.dailypay.com/oauth2/token"]}]}]}]}]},{"$$mdtype":"Tag","name":"JsonSchema","attributes":{"schema":{"$ref":"../../reference/authorization/client-credentials-sample.yaml#/components/schemas/ClientCredentialsTokenRequest"},"options":{},"schemaResolved":{"openapi":"3.1.0","components":{"schemas":{"__root":{"$ref":"#/components/schemas/ClientCredentialsTokenRequest"},"ClientCredentialsTokenRequest":{"type":"object","title":"Client credentials flow","required":["grant_type","scope","client_id","client_secret"],"properties":{"grant_type":{"type":"string","description":"The OAuth2 grant type","const":"client_credentials"},"scope":{"type":"string","description":"A space-separated list of scopes to request","example":"client:lookup health:read"},"client_id":{"description":"The client id of the application requesting the token.","type":"string","example":"your_client_id"},"client_secret":{"type":"string","description":"The client secret of the application requesting the token.","example":"your_client_secret"}}}}}},"schemaResolvedErrors":[]},"children":[]},{"$$mdtype":"Tag","name":"OpenApiCodeSample","attributes":{"descriptionFile":"oas-products/rest/reference/authorization/client-credentials-sample.yaml","operationId":"token","parameters":{},"environments":{},"codeSamplesResolved":[{"lang":"javascript","title":"JavaScript","source":"const formData = {\n  grant_type: 'client_credentials',\n  scope: 'client:lookup health:read',\n  client_id: 'your_client_id',\n  client_secret: 'your_client_secret'\n};\n\nconst resp = await fetch(\n  `https://auth.dailypay.com/oauth2/token`,\n  {\n    method: 'POST',\n    headers: {\n      'Content-Type': 'application/x-www-form-urlencoded'\n    },\n    body: new URLSearchParams(formData).toString()\n  }\n);\n\nconst data = await resp.text();\nconsole.log(data);"},{"lang":"go","title":"Go","source":"package main\n\nimport (\n  \"fmt\"\n  \"net/url\"\n  \"strconv\"\n  \"strings\"\n  \"net/http\"\n  \"io/ioutil\"\n)\n\nfunc main() {\n  reqUrl := \"https://auth.dailypay.com/oauth2/token\"\n  data := url.Values{}\n  data.Set(\"grant_type\", \"client_credentials\")\n  data.Set(\"scope\", \"client:lookup health:read\")\n  data.Set(\"client_id\", \"your_client_id\")\n  data.Set(\"client_secret\", \"your_client_secret\")\n  req, err := http.NewRequest(\"POST\", reqUrl, strings.NewReader(data.Encode()))\n  if err != nil {\n    panic(err)\n  }\n  req.Header.Add(\"Content-Type\", \"application/x-www-form-urlencoded\")\n  req.Header.Add(\"Content-Length\", strconv.Itoa(len(data.Encode())))\n  res, err := http.DefaultClient.Do(req)\n  if err != nil {\n    panic(err)\n  }\n  defer res.Body.Close()\n  body, err := ioutil.ReadAll(res.Body)\n  if err != nil {\n    panic(err)\n  }\n\n  fmt.Println(res)\n  fmt.Println(string(body))\n}"},{"lang":"csharp","title":"C#","source":"using System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing System.Collections.Generic;\n\npublic class Program\n{\n  public static async Task Main()\n  {\n    System.Net.Http.HttpClient client = new();\n\n\n    List<KeyValuePair<string, string>> postData = new List<KeyValuePair<string, string>>();\n    postData.Add(new KeyValuePair<string, string>(\"grant_type\", \"client_credentials\"));\n    postData.Add(new KeyValuePair<string, string>(\"scope\", \"client:lookup health:read\"));\n    postData.Add(new KeyValuePair<string, string>(\"client_id\", \"your_client_id\"));\n    postData.Add(new KeyValuePair<string, string>(\"client_secret\", \"your_client_secret\"));\n\n    using HttpResponseMessage request = await client.PostAsync(\"https://auth.dailypay.com/oauth2/token\", new FormUrlEncodedContent(postData));\n    string response = await request.Content.ReadAsStringAsync();\n\n    Console.WriteLine(response);\n  }\n}"},{"lang":"java","title":"Java","source":"import java.net.*;\nimport java.net.http.*;\nimport java.util.*;\nimport java.nio.charset.StandardCharsets;\nimport java.util.stream.Collectors;\n\npublic class App {\n  public static void main(String[] args) throws Exception {\n    var httpClient = HttpClient.newBuilder().build();\n\n    HashMap<String, String> params = new HashMap<>();\n    params.put(\"grant_type\", \"client_credentials\");\n    params.put(\"scope\", \"client:lookup health:read\");\n    params.put(\"client_id\", \"your_client_id\");\n    params.put(\"client_secret\", \"your_client_secret\");\n\n    var form = params.keySet().stream()\n      .map(key -> key + \"=\" + URLEncoder.encode(params.get(key), StandardCharsets.UTF_8))\n      .collect(Collectors.joining(\"&\"));\n\n    var host = \"https://auth.dailypay.com\";\n    var pathname = \"/oauth2/token\";\n    var request = HttpRequest.newBuilder()\n      .POST(HttpRequest.BodyPublishers.ofString(form))\n      .uri(URI.create(host + pathname ))\n      .header(\"Content-Type\", \"application/x-www-form-urlencoded\")\n      .build();\n\n    var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());\n\n    System.out.println(response.body());\n  }\n}"},{"lang":"python","title":"Python","source":"import requests\n\nurl = \"https://auth.dailypay.com/oauth2/token\"\n\npayload = {\n  \"grant_type\": \"client_credentials\",\n  \"scope\": \"client:lookup health:read\",\n  \"client_id\": \"your_client_id\",\n  \"client_secret\": \"your_client_secret\"\n}\n\nheaders = {\"Content-Type\": \"application/x-www-form-urlencoded\"}\n\nresponse = requests.post(url, data=payload, headers=headers)\n\ndata = response.json()\nprint(data)"},{"lang":"ruby","title":"Ruby","source":"require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI('https://auth.dailypay.com/oauth2/token')\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest['Content-Type'] = 'application/x-www-form-urlencoded'\nrequest.body = URI.encode_www_form({\n  grant_type: 'client_credentials',\n  scope: 'client:lookup health:read',\n  client_id: 'your_client_id',\n  client_secret: 'your_client_secret'\n})\n\nresponse = http.request(request)\nputs response.read_body\n"},{"lang":"shell","title":"cURL","source":"curl -i -X POST \\\n  https://auth.dailypay.com/oauth2/token \\\n  -H 'Content-Type: application/x-www-form-urlencoded' \\\n  -d grant_type=client_credentials \\\n  -d 'scope=client:lookup health:read' \\\n  -d client_id=your_client_id \\\n  -d client_secret=your_client_secret"}]},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The resulting access token can be used to make requests to the DailyPay REST API:"]},{"$$mdtype":"Tag","name":"OpenApiResponseSample","attributes":{"descriptionFile":"oas-products/rest/reference/authorization/client-credentials-sample.yaml","operationId":"token","responseSamplesResolved":[{"lang":"json","title":"200 application/json","source":"{\n  \"access_token\": \"dpo_38347Ae178B4a16C7e42F292c6912E7710c8\",\n  \"refresh_token\": \"dpo_38347Ae178B4a16C7e42F292c6912E7710c9\",\n  \"token_type\": \"bearer\",\n  \"scope\": \"user:read_write\",\n  \"id_token\": \"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.4FjJ3eZJYJj7J9Jf\",\n  \"expires_in\": 3600\n}"},{"lang":"json","title":"default application/json","source":"{\n  \"error\": \"unexpected_error\",\n  \"error_description\": \"An internal server error has occurred.\",\n  \"status_code\": 500,\n  \"error_hint\": \"string\"\n}"}]},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The authorization code, access token, and refresh tokens can vary in size but will typically remain under 4096 bytes."]}]}]},"headings":[{"value":"Client Credentials Flow","id":"client-credentials-flow","depth":1}],"frontmatter":{"seo":{"title":"Client Credentials Flow"}},"lastModified":"2026-07-14T14:30:25.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/rest/guides/auth/client-credentials-flow","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}