{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-products/rest/guides/sidebars.yaml","oas-products/rest/reference/authorization/refresh-sample.yaml":"oas-products/rest/reference/authorization/refresh-sample.yaml"},"props":{"metadata":{"markdoc":{"tagList":["partial","json-schema","openapi-code-sample","openapi-response-sample"]},"type":"markdown"},"seo":{"title":"Refresh an Access Token","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":"refresh-an-access-token","__idx":0},"children":["Refresh an Access Token"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When your access token expires, you can use a refresh token to obtain a new access token without requiring the user to re-authenticate."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Complete details of the specification are available in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.rfc-editor.org/rfc/rfc6749#section-6"},"children":["RFC 6749 section 6"]},"."]},{"$$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/refresh-sample.yaml#/components/schemas/RefreshTokenRequest"},"options":{},"schemaResolved":{"openapi":"3.1.0","components":{"schemas":{"__root":{"$ref":"#/components/schemas/RefreshTokenRequest"},"RefreshTokenRequest":{"type":"object","title":"Refresh token","required":["grant_type","refresh_token","client_id"],"properties":{"grant_type":{"type":"string","description":"The OAuth2 grant type","const":"refresh_token"},"refresh_token":{"type":"string","description":"A refresh token received from a previous token request","example":"rt.ML_PsNjfQA4M7iupH_3jw"},"client_id":{"description":"The client id of the application refreshing the token.","type":"string","example":"your_client_id"},"client_secret":{"type":"string","description":"The client secret of the application refreshing the token, if available.","example":"your_client_secret"},"scope":{"type":"string","description":"A space-separated list of scopes to request in the access token. If not provided, the scopes will default to those originally granted.","example":"user:read"}}}}}},"schemaResolvedErrors":[]},"children":[]},{"$$mdtype":"Tag","name":"OpenApiCodeSample","attributes":{"descriptionFile":"oas-products/rest/reference/authorization/refresh-sample.yaml","operationId":"token","parameters":{},"environments":{},"codeSamplesResolved":[{"lang":"javascript","title":"JavaScript","source":"const formData = {\n  grant_type: 'refresh_token',\n  refresh_token: 'rt.ML_PsNjfQA4M7iupH_3jw',\n  client_id: 'your_client_id',\n  client_secret: 'your_client_secret',\n  scope: 'user:read'\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\", \"refresh_token\")\n  data.Set(\"refresh_token\", \"rt.ML_PsNjfQA4M7iupH_3jw\")\n  data.Set(\"client_id\", \"your_client_id\")\n  data.Set(\"client_secret\", \"your_client_secret\")\n  data.Set(\"scope\", \"user:read\")\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\", \"refresh_token\"));\n    postData.Add(new KeyValuePair<string, string>(\"refresh_token\", \"rt.ML_PsNjfQA4M7iupH_3jw\"));\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    postData.Add(new KeyValuePair<string, string>(\"scope\", \"user:read\"));\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\", \"refresh_token\");\n    params.put(\"refresh_token\", \"rt.ML_PsNjfQA4M7iupH_3jw\");\n    params.put(\"client_id\", \"your_client_id\");\n    params.put(\"client_secret\", \"your_client_secret\");\n    params.put(\"scope\", \"user:read\");\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\": \"refresh_token\",\n  \"refresh_token\": \"rt.ML_PsNjfQA4M7iupH_3jw\",\n  \"client_id\": \"your_client_id\",\n  \"client_secret\": \"your_client_secret\",\n  \"scope\": \"user:read\"\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: 'refresh_token',\n  refresh_token: 'rt.ML_PsNjfQA4M7iupH_3jw',\n  client_id: 'your_client_id',\n  client_secret: 'your_client_secret',\n  scope: 'user:read'\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=refresh_token \\\n  -d refresh_token=rt.ML_PsNjfQA4M7iupH_3jw \\\n  -d client_id=your_client_id \\\n  -d client_secret=your_client_secret \\\n  -d scope=user:read"}]},"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/refresh-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":"Refresh an Access Token","id":"refresh-an-access-token","depth":1}],"frontmatter":{"seo":{"title":"Refresh an Access Token"}},"lastModified":"2026-07-14T14:30:25.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/rest/guides/auth/refresh-token","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}