# Customising authentication redirects

## Overview

After the end-user completes the authentication flow, they will be redirected to a **default** **final** **url** that's either a **success** or **failure** **screen** before they go back to your app.&#x20;

These urls can be customized when you're calling one of the `/auth` endpoints.

***

## Authentication Flow Final URL

When the user authenticates a health account (e.g. Oura), before they go back to your app, they see a final URL (screen) of the authentication flow is either a <mark style="color:green;">success</mark> or <mark style="color:red;">failure</mark> screen.

<div align="center"><figure><img src="https://464213908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVGMJVuZnZyOtvV4b53cY%2Fuploads%2F7PxwtMisS2aHpOWMy1YE%2FCapture%20d%E2%80%99e%CC%81cran%202025-03-28%20a%CC%80%2021.17.40.png?alt=media&#x26;token=49efdbb8-3e40-42dd-b8aa-81a65162aeea" alt="" width="188"><figcaption><p>Default <strong>Success</strong> Redirect URL</p></figcaption></figure> <figure><img src="https://464213908-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVGMJVuZnZyOtvV4b53cY%2Fuploads%2FpkmkdnwCVib23TkG4obF%2FCapture%20d%E2%80%99e%CC%81cran%202025-03-28%20a%CC%80%2021.13.32.png?alt=media&#x26;token=b7609718-69d7-43ee-b97c-c59340f225a2" alt="" width="188"><figcaption><p>Default <strong>Failure</strong> Redirect URL</p></figcaption></figure></div>

&#x20;The final url will append the following parameters:

* <mark style="color:orange;">`user_id`</mark>  (not Null)
* `resource`  (not Null)
* `reference_id` (can be Null - if you did not pass it in the auth endpoint).

<pre class="language-url" data-title="Success Auth URL (Example)"><code class="lang-url"><strong>https://widget.tryterra.co/session/demo/success?user_id=bc205b50-dabe-4680-9d35-38517b915dc1&#x26;resource=GOOGLE&#x26;reference_id=null 
</strong></code></pre>

***

## **How to Customize the Redirect URLs?**

&#x20;Terra provides these urls by default, and they can also be customized in the `/auth` endpoints. They can be specified in the **body** of the authentication request as:

* <mark style="color:green;">`auth_success_redirect_url`</mark>  &#x20;
* <mark style="color:red;">`auth_failure_redirect_url`</mark>

***

## **Different ways to Customize the Auth Result URL**

You can redirect to a:

* **Web Page:** A specific page on your web application, including any useful query parameters.
  * Example: `https://somereallycoolcompany.com?terra_auth_success=true`
* **Deep Link:** A **deep** **link** into your mobile application.
  * Example: `reallycoolapp://success`&#x20;

{% hint style="warning" %}
## Mobile-based integrations

* When using the widget, when the user selects one of the [Mobile SDK-based integrations](../mobile-only-sources) (e.g. Apple Health, Samsung Health, Health Connect), they will by default be redirected to the <mark style="color:green;">`auth_success_redirect_url`</mark> with a **null** <mark style="color:orange;">`user_id`</mark> <mark style="color:orange;"></mark><mark style="color:orange;">.</mark>
* This Redirect URL can be used to redirect your end-user to your mobile app instead so that they complete the connection flow to the Mobile-only integrations using **Deep Links.**
{% endhint %}
