{"componentChunkName":"component---src-templates-simple-markdown-js","path":"/api-docs/best-practices/authentication/","matchPath":"","result":{"data":{"markdownRemark":{"html":"<h1 style=\"position:relative;\"><a href=\"#authentication\" aria-label=\"authentication permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"authentication\"></div>Authentication</h1>\n<p>To make a payment using any of the Ripple Payments API operations, you need a valid <em>access token</em>.</p>\n<p>This access token is required by all Ripple Payments API operations (except the Authentication operation itself). You must include a valid access token in the <code class=\"language-text\">Authorization</code> header of each request.</p>\n<p>Ripple Payments provides a secure model for authentication and authorization by providing access tokens scoped for a set of credentials.</p>\n<p>The Authentication operation returns an access token in the <code class=\"language-text\">access_token</code> response field. You must include your <code class=\"language-text\">client_id</code> and <code class=\"language-text\">client_secret</code> in the JSON body to get a valid access token.</p>\n<div class=\"admonition admonition-attention\"><div class=\"admonition-heading\"><h5><span class=\"admonition-icon\"><i></i></span>Note</h5></div><div class=\"admonition-content\"><p>The length of the access token isn't fixed, hence it can vary. Avoid validating tokens based on character length.</p></div></div>\n<h2 style=\"position:relative;\"><a href=\"#generate-client-id-and-client-secret\" aria-label=\"generate client id and client secret permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"generate-client-id-and-client-secret\"></div>Generate client ID and client secret</h2>\n<p>You need your <em>client ID</em> and <em>client secret</em> to obtain an access token.</p>\n<p>If you don't already have your client ID and client secret, do the following:</p>\n<ol>\n<li>\nLog in to \n<a href=\"https://home.ripple.com\">Ripple Payments</a>\n.\n</li>\n<li>\nOn the top right of the page, click the \n<strong>Settings</strong>\n gear icon.\n</li>\n<li>\nUnder \n<strong>Integration</strong>\n, select \n<strong>API Credentials</strong>\n.\n</li>\n<li>\nOn the top right of the page, select the access environment from the dropdown list. For example, to provision credentials for the Test environment, select \n<strong>Test</strong>\n from the dropdown list.\n</li>\n<li>\nIn the upper right corner of the page, click \n<strong>New Credential</strong>\n.\n</li>\n<li>\nIn the \n<strong>Credential name</strong>\n field, enter a name for the credential.\n</li>\n<li>\nClick \n<strong>Save &#x26; Generate Key</strong>\n.\n</li>\n</ol>\n<!--![settings-api-select-env](../../payments-direct/images/rnh-settings-select-env.png)-->\n<div class=\"admonition admonition-warning\"><div class=\"admonition-heading\"><h5><span class=\"admonition-icon\"><i></i></span>Warning</h5></div><div class=\"admonition-content\"><p>The <em>client secret</em> is displayed only once when you are creating new credentials.</p><p>You can't retrieve the secret after exiting this page.</p><p>Copy and store the client secret securely and share it with authorized individuals in accordance with your organization's security policy.</p></div></div>\n<p>You can now use the client ID and client secret to generate access tokens using the authentication operation.</p>\n<p>We recommend rotating your API credentials at regular intervals in accordance with your organization's security policy.</p>\n<h2 style=\"position:relative;\"><a href=\"#fetch-an-access-token\" aria-label=\"fetch an access token permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"fetch-an-access-token\"></div>Fetch an access token</h2>\n<p>Once you have your <em>client ID</em> and <em>client secret</em>, follow these steps to obtain an access token that you can use with Ripple Payments API calls:</p>\n<h3 style=\"position:relative;\"><a href=\"#determine-the-desired-environment\" aria-label=\"determine the desired environment permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"determine-the-desired-environment\"></div>Determine the desired environment</h3>\n<p>The first step to fetching an access token it to determine the environment that you want to access.</p>\n<p>The following table describes the differences in types of partners and currency for the environments that provide Ripple Payments API access. Take note of the environment string for the environment you want to access.</p>\n<table>\n<thead>\n<tr>\n<th><strong>Environment</strong></th>\n<th><strong>Request URL</strong></th>\n<th><strong>Environment String</strong></th>\n<th><strong>Partners</strong></th>\n<th><strong>Currency</strong></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Test</strong></td>\n<td><code class=\"language-text\">https://api.test.ripple.com/v2/oauth/token</code></td>\n<td><code class=\"language-text\">test</code></td>\n<td>Simulated</td>\n<td>Simulated</td>\n</tr>\n<tr>\n<td><strong>Production</strong></td>\n<td><code class=\"language-text\">https://api.ripple.com/v2/oauth/token</code></td>\n<td><code class=\"language-text\">prod</code></td>\n<td>Actual</td>\n<td>Actual</td>\n</tr>\n</tbody>\n</table>\n<h3 style=\"position:relative;\"><a href=\"#request-the-access-token\" aria-label=\"request the access token permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"request-the-access-token\"></div>Request the access token</h3>\n<p>The request format for an authentication request is as follows:</p>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"41061270106398260000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`POST https://api.ripple.com/v2/oauth/token\nContent-Type: application/json\n{\n   &quot;grant_type&quot;:&quot;client_credentials&quot;,\n   &quot;client_id&quot;:&quot;{YOUR_CLIENT_ID}&quot;,\n   &quot;client_secret&quot;:&quot;{YOUR_CLIENT_SECRET}&quot;,\n   &quot;audience&quot;: &quot;urn:ripplexcurrent-{ENVIRONMENT_STRING}:{YOUR_TENANT_ID}&quot;\n}`, `41061270106398260000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-41061270106398260000\">Copied!</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\">POST https<span class=\"token operator\">:</span><span class=\"token comment\">//api.ripple.com/v2/oauth/token</span>\nContent-Type<span class=\"token operator\">:</span> application/json\n<span class=\"token punctuation\">{</span>\n   <span class=\"token property\">\"grant_type\"</span><span class=\"token operator\">:</span><span class=\"token string\">\"client_credentials\"</span><span class=\"token punctuation\">,</span>\n   <span class=\"token property\">\"client_id\"</span><span class=\"token operator\">:</span><span class=\"token string\">\"{YOUR_CLIENT_ID}\"</span><span class=\"token punctuation\">,</span>\n   <span class=\"token property\">\"client_secret\"</span><span class=\"token operator\">:</span><span class=\"token string\">\"{YOUR_CLIENT_SECRET}\"</span><span class=\"token punctuation\">,</span>\n   <span class=\"token property\">\"audience\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"urn:ripplexcurrent-{ENVIRONMENT_STRING}:{YOUR_TENANT_ID}\"</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n      </div>\n<p>The expected values are as follows:</p>\n<table>\n<thead>\n<tr>\n<th><div style=\"width:130px\"><strong>Key</strong></div></th>\n<th><strong>Value</strong></th>\n<th><strong>Description</strong></th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code class=\"language-text\">grant_type</code></td>\n<td><code class=\"language-text\">client_credentials</code></td>\n<td>Set the grant-type for this client credentials request.</td>\n</tr>\n<tr>\n<td><code class=\"language-text\">client_id</code></td>\n<td><em>{YOUR_CLIENT_ID}</em></td>\n<td>Log into Ripple Payments UI to retrieve your client ID for Ripple Payments.</td>\n</tr>\n<tr>\n<td><code class=\"language-text\">client_secret</code></td>\n<td><em>{YOUR_CLIENT_SECRET}</em></td>\n<td>Retrieve the client secret for Ripple Payments that was generated when you created the current set of credentials in Ripple Payments UI.</td>\n</tr>\n<tr>\n<td><code class=\"language-text\">audience</code></td>\n<td><code class=\"language-text\">urn:ripplexcurrent-</code><em>{ENVIRONMENT_STRING}</em><code class=\"language-text\">:</code><em>{YOUR_TENANT_ID}</em></td>\n<td>The value of the <code class=\"language-text\">audience</code> field is based on <a href=\"https://en.wikipedia.org/wiki/Uniform_Resource_Name\">URN</a> syntax. The second component of the URN must refer to the environment which you want to access. Ripple integration engineers provide you your tenant ID (the third component of the URN) during training.</td>\n</tr>\n</tbody>\n</table>\n<p>Examples:</p>\n<p><strong>Request Example (Production Environment Success)</strong> – A successful request to a production environment may look similar to the following example:</p>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"9587109795099490000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`POST https://api.ripple.com/v2/oauth/token\nContent-Type: application/json\n{\n    &quot;grant_type&quot;: &quot;client_credentials&quot;,\n    &quot;client_id&quot;: &quot;{YOUR_CLIENT_ID}&quot;,\n    &quot;client_secret&quot;: &quot;{YOUR_CLIENT_SECRET}&quot;,\n    &quot;audience&quot;: &quot;urn:ripplexcurrent-prod:{YOUR_TENANT_ID}&quot;\n}`, `9587109795099490000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-9587109795099490000\">Copied!</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\">POST https<span class=\"token operator\">:</span><span class=\"token comment\">//api.ripple.com/v2/oauth/token</span>\nContent-Type<span class=\"token operator\">:</span> application/json\n<span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"grant_type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"client_credentials\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"client_id\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"{YOUR_CLIENT_ID}\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"client_secret\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"{YOUR_CLIENT_SECRET}\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"audience\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"urn:ripplexcurrent-prod:{YOUR_TENANT_ID}\"</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n      </div>\n<p><strong>Response Example (Production Environment Success)</strong> – A successful request returns a response similar to the following example:</p>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"73427138218521805000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`{\n    &quot;access_token&quot;: &quot;eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ&quot;,\n    &quot;expires_in&quot;: 3600,\n    &quot;token_type&quot;: &quot;Bearer&quot;,\n    &quot;scope&quot;: &quot;keys:read keys:write payments:create quotes:create identities:create audit:read&quot;\n}`, `73427138218521805000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-73427138218521805000\">Copied!</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"access_token\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"expires_in\"</span><span class=\"token operator\">:</span> <span class=\"token number\">3600</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"token_type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Bearer\"</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"scope\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"keys:read keys:write payments:create quotes:create identities:create audit:read\"</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n      </div>\n<h3 style=\"position:relative;\"><a href=\"#test-the-access-token\" aria-label=\"test the access token permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"test-the-access-token\"></div>Test the access token</h3>\n<p>Use the <code class=\"language-text\">/oauth/token/test</code> endpoint to verify the validity of your access token for a specific Ripple environment and determine the remaining time before it expires.</p>\n<h4 style=\"position:relative;\"><a href=\"#example-token-test\" aria-label=\"example token test permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"example-token-test\"></div>Example token test</h4>\n<p>This example demonstrates how to use the <code class=\"language-text\">/oauth/token/test</code> endpoint to test an access token.</p>\n<p>Here, we apply the access token <code class=\"language-text\">eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ</code> to the <code class=\"language-text\">Authorization: Bearer</code> header.</p>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"34186577283053010000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`GET https://api.ripple.com/v2/oauth/token/test\nAuthorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ`, `34186577283053010000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-34186577283053010000\">Copied!</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\">GET https<span class=\"token operator\">:</span><span class=\"token comment\">//api.ripple.com/v2/oauth/token/test</span>\nAuthorization<span class=\"token operator\">:</span> Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ</code></pre></div>\n      </div>\n<div class=\"admonition admonition-warning\"><div class=\"admonition-heading\"><h5><span class=\"admonition-icon\"><i></i></span>Caution : Access tokens are confidential</h5></div><div class=\"admonition-content\"><p>Remember to replace the example token <code class=\"language-text\">eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ</code> with your actual access token, and never share your access token publicly.</p></div></div>\n<h4 style=\"position:relative;\"><a href=\"#example-token-test-response\" aria-label=\"example token test response permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"example-token-test-response\"></div>Example token test response</h4>\n<p>The response is a JSON object with the following properties:</p>\n<ul>\n<li>\n<code class=\"language-text\">message</code>\n : Indicates the status of the access token.\n</li>\n<li>\n<code class=\"language-text\">seconds_to_expiry</code>\n : Represents the number of seconds remaining until the access token expires.\n</li>\n</ul>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"60590785340359840000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`{\n&quot;message&quot;: &quot;token_ok&quot;,\n&quot;seconds_to_expiry&quot;: 3600\n}`, `60590785340359840000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-60590785340359840000\">Copied!</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n<span class=\"token property\">\"message\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"token_ok\"</span><span class=\"token punctuation\">,</span>\n<span class=\"token property\">\"seconds_to_expiry\"</span><span class=\"token operator\">:</span> <span class=\"token number\">3600</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n      </div>\n<h2 style=\"position:relative;\"><a href=\"#authorize-ripple-payments-api-operations-using-the-access-token\" aria-label=\"authorize ripple payments api operations using the access token permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"authorize-ripple-payments-api-operations-using-the-access-token\"></div>Authorize Ripple Payments API operations using the access token</h2>\n<p>Ripple Payments uses <a href=\"https://tools.ietf.org/html/rfc6750\">Bearer Token Authorization</a> for all operations (except the Authentication operation itself). To make successful Ripple Payments API requests, include a valid access token in the <code class=\"language-text\">Authorization</code> header of each request in the following format:</p>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"5294439247132421000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ`, `5294439247132421000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-5294439247132421000\">Copied!</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\">Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ</code></pre></div>\n      </div>\n<p>To use this in an in an API request, add the value of the <code class=\"language-text\">access_token</code> field to the <strong>Authorization</strong> header for all Ripple Payments API operations (except the Authentication operation itself). Remember to add <code class=\"language-text\">Bearer</code> (including a space) before the access token.</p>\n<p>For example:</p>\n<div class=\"code-wrapper\">\n        <div class=\"gatsby-code-button-container\"\n             data-toaster-id=\"44923554619953100000\"\n             data-toaster-duration=\"1500\"\n             onClick=\"copyCodeToClipboard(`GET https://api.ripple.com/v2/payments/{YOUR_PAYMENT_ID}\nAuthorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ`, `44923554619953100000`)\"\n        >\n          <div class=\"gatsby-code-button\" title=\"Copy the code snippet\">Copy</div>\n          <div class=\"done-indicator done-indicator-44923554619953100000\">Copied!</div>\n        </div>\n        <div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\">GET https<span class=\"token operator\">:</span><span class=\"token comment\">//api.ripple.com/v2/payments/{YOUR_PAYMENT_ID}</span>\nAuthorization<span class=\"token operator\">:</span> Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJ</code></pre></div>\n      </div>\n<h2 style=\"position:relative;\"><a href=\"#access-token-expiration-and-caching\" aria-label=\"access token expiration and caching permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a><div class=\"hidden-anchor\" id=\"access-token-expiration-and-caching\"></div>Access token expiration and caching</h2>\n<p>Access tokens are valid for 1 hour. After you get a new token, it is cached for a limited amount of time. To avoid problems caused by double caching, don't cache the token client-side. If you do cache the token, you must clear the cache within the time period specified by the <code class=\"language-text\">expires_in</code> field (as specified by the <code class=\"language-text\">exp</code> claim in the JWT) in the response body.</p>\n<!-- Doesn't apply to RPD 2.0\n\n## IP allowlisting\n\nThe Authentication operation is protected by the {{process.env.VAR_RP}} allowlist. If you have already allowlisted your middleware IP to access the {{process.env.VAR_RP}} API, you don't need to take any further action. For instructions on adding your middleware IP to the {{process.env.VAR_RP}} allowlist, see [IP allowlisting](ip-allowlisting.md).\n\n-->","headings":[{"value":"Authentication","depth":1},{"value":"Generate client ID and client secret","depth":2},{"value":"Fetch an access token","depth":2},{"value":"Determine the desired environment","depth":3},{"value":"Request the access token","depth":3},{"value":"Test the access token","depth":3},{"value":"Example token test","depth":4},{"value":"Example token test response","depth":4},{"value":"Authorize Ripple Payments API operations using the access token","depth":2},{"value":"Access token expiration and caching","depth":2}]},"contentItem":{"data":{"lastModified":"2025-11-13T00:24:58.000Z","enableToc":null,"disableLastModified":null,"tocMaxDepth":3,"requestLogin":false}},"siteConfig":{"enableToc":false,"disableLastModified":true,"tocMaxDepth":4}},"pageContext":{"matchPath":"","id":"33cb32a7-64b3-553c-800c-c5627d27c171__redocly content/api-docs/best-practices/authentication/","seo":{"title":"Authentication","description":null,"image":"","keywords":null,"jsonLd":null,"lang":null,"siteUrl":null},"pageId":"api-docs/best-practices/authentication.md","pageBaseUrl":"/api-docs/best-practices/authentication","type":"markdown","toc":{"enable":true,"maxDepth":3,"headings":[{"depth":1,"value":"Authentication","id":"authentication"},{"depth":2,"value":"Generate client ID and client secret","id":"generate-client-id-and-client-secret"},{"depth":2,"value":"Fetch an access token","id":"fetch-an-access-token"},{"depth":3,"value":"Determine the desired environment","id":"determine-the-desired-environment"},{"depth":3,"value":"Request the access token","id":"request-the-access-token"},{"depth":3,"value":"Test the access token","id":"test-the-access-token"},{"depth":4,"value":"Example token test","id":"example-token-test"},{"depth":4,"value":"Example token test response","id":"example-token-test-response"},{"depth":2,"value":"Authorize Ripple Payments API operations using the access token","id":"authorize-ripple-payments-api-operations-using-the-access-token"},{"depth":2,"value":"Access token expiration and caching","id":"access-token-expiration-and-caching"}]},"data":{"title":"","tocMaxDepth":3},"catalogInfo":null,"link":"/api-docs/best-practices/authentication/","sidebarName":"__root-sidebar__-data-69308394-sidebars.yaml","isLanding":false,"showPrevButton":null,"showNextButton":null,"apiVersions":null,"apiVersionId":null,"isDefaultApiVersion":null}},"staticQueryHashes":["1123603147","1302185487","1344209882","1398840060","1520077861","1975142765","2667623876","2950305614","3240152602","3743992808","561138138"]}