> For the complete documentation index, see [llms.txt](https://oten.gitbook.io/identity-support/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://oten.gitbook.io/identity-support/integration/integration-document/idp-integration/single-page-application-client.md).

# Single page application client

This page helps you determine if a single page application (SPA) is the right choice for the application you are integrating with OXU Identity and how to configure guiding.

This section is part of OAuth 2.0 / OpenID Connect (OIDC) integration.\
Currently, the Quick Start guide and technical support for this client type are optimized for the **React**, **Javascript** framework.

### Why am i here? <a href="#i-am-new.-where-should-i-start" id="i-am-new.-where-should-i-start"></a>

If this is your first time integrating with Oten Identity, start with:

* **Creating an** [**integration app**](/identity-support/integration/integration-document.md)
* **Creating a regular web application client**
* **Using quick start to integrate authentication into your React**, **Javascript Single Page application**

#### What is a Single page application? <a href="#what-is-a-single-page-application" id="what-is-a-single-page-application"></a>

In the context of OXU Identity, a single page application is a browser-based application where all logic runs on the client side.

Authentication happens directly in the browser, and no backend server is used to manage login sessions or store secrets.

Choose a single page application if your app:

* Runs entirely in the browser (for example: React, Vue, Angular)
* Does not have a backend handling authentication
* Cannot safely store a client secret

This client type is designed for public clients where secrets must not be exposed.

#### Key characteristics include:

* Authentication is handled using OAuth 2.0 / OpenID Connect
* Uses redirect-based authentication
* Integrates with Oten Identity via the Authorization Code flow with PKCE
* Does not use a client secret
* Client configuration is managed through the Oten Developer Portal

#### Why use a SPA client?

Use this client type when:

* Your app runs fully in the browser
* You do not control or rely on a backend for authentication
* You need a fast, lightweight login experience
* You want to integrate authentication using frontend SDKs

SPA clients are optimized for modern web applications with minimal infrastructure.

#### What should i do next?

If you already know that your application is a single page application, continue by opening the **quick start** tab.

In quick start, you will find:

* Example integration code
* Step-by-step authentication guidance
* A working sample for frontend integration

Follow the instructions to integrate login with Oten into your application.

**Prerequisites**

* An **Integration application** already exists
* You know the public URL of your frontend application
* You understand basic OAuth / OIDC login flows
* You can configure redirect URLs in your frontend app

**Recommended knowledge:**

* OAuth 2.0 Authorization Code Flow with PKCE
* OpenID Connect basics
* Browser security concepts (redirects, tokens)

### I already understand. How do I proceed step by step?

#### Step 1: Open create client <a href="#step-1-open-create-client" id="step-1-open-create-client"></a>

1. Sign in to the [**OXU Developer portal**](https://developer.oten.live/)
2. Navigate to: **App Management** → **Integration App** → **App detail**
3. Select **Create app**<br>

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FSgG9NnCwSfXVn6ZIvBiL%2Fimage.png?alt=media&amp;token=54c7ec62-f441-4048-95b4-de943d4d6606" alt=""><figcaption></figcaption></figure>

You are now on the **Create client** screen.

#### Step 2: Select client type <a href="#step-2-select-client-type" id="step-2-select-client-type"></a>

Under **Client type**, choose:

**Single page application**

This option is designed for browser-based applications that do not use a backend to handle authentication.

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FxYnLqzpS3l4WeJMdUe6W%2Fimage.png?alt=media&amp;token=fd0e194e-931b-4966-86f4-7282b657b611" alt=""><figcaption></figcaption></figure>

#### Step 3: Review client characteristics

By selecting **Single page application**, the client will:

* Use OAuth 2.0 Authorization Code Flow with **PKCE**
* **Not** use a Client Secret
* Authenticate users directly from the browser
* Exchange tokens without exposing sensitive credentials
* Rely strictly on redirect URI validation

This client type is considered a **public client**.

#### Step 4: Configure redirect URIs <a href="#step-4-configure-redirect-uris" id="step-4-configure-redirect-uris"></a>

In the **Configure client URIs** section, enter:

**Redirect URIs** (required)

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FzSRiyjFA3EbRYwurgVFm%2Fimage.png?alt=media&amp;token=5d427ae1-1553-4898-ac62-f4495567288b" alt=""><figcaption></figcaption></figure>

These URLs define where users are redirected after successful login.

**Guidelines:**

* Must exactly match your frontend routes
* HTTPS is recommended (required in production)
* Multiple URLs can be added
* Separate entries by comma or newline

**Example:**

`https://app.example.com/callback, http://localhost:3000/callback`

> Any redirect URI not listed here will be rejected during authentication.

#### Step 5: Create the client <a href="#step-5-create-the-client" id="step-5-create-the-client"></a>

After verifying the configuration:

1. Confirm **Single Page Application** is selected
2. Review redirect URIs
3. Click **Create client**<br>

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FcJoopkrldk0xegm7hNP8%2Fimage.png?alt=media&amp;token=c1e350cd-6e6e-46ea-90b8-17bb772861bb" alt=""><figcaption></figcaption></figure>

The system creates a new SPA client.

#### Step 6: Use Quick start to integrate your frontend <a href="#step-6-use-quick-start-to-integrate-your-frontend" id="step-6-use-quick-start-to-integrate-your-frontend"></a>

After onboarding, you are redirected to **Client detail**, which contains two tabs:

* **Quick start**
* **Configure**

By default, the **Quick start** tab is displayed. This section provides ready-to-use integration guidance based on your selected client type.

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FlacU9eeZA7EaSE5XhS0g%2Fimage.png?alt=media&amp;token=c3209cde-1cac-414e-84a0-45d7e02a6652" alt=""><figcaption></figcaption></figure>

**6.1 Select your technology**

Under **Select your technology**, choose the framework used by your application.

For Single Page Applications, supported options include:

* **React**
* **JavaScript (Vanilla)**

Selecting a technology updates the setup instructions and code samples accordingly.

**6.2 Review prerequisites**

Before proceeding with the integration, ensure the following requirements are met:

* **Node.js 18 LTS or newer**
* One of the following package managers:
  * npm 9+
  * yarn 1.22+
  * pnpm 8+
* An active **Oten IDP account**
* A configured **Single page application client**

> **Note**\
> For React-based setups, this Quick Start supports **React 18.x and newer**.

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FyyihPdVheaWQidLED8Rz%2Fimage.png?alt=media&amp;token=56b1bec2-aa51-419f-939c-14dd74740adc" alt=""><figcaption></figcaption></figure>

**6.3 Create a new react project**

Create a new React project using Vite:

* Initialize the project
* Navigate into the project directory
* Install dependencies<br>

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FBUgFMY4hwanw8q2woauu%2Fimage.png?alt=media&amp;token=0b9f4067-ab28-416f-b250-d406f8be36f0" alt=""><figcaption></figcaption></figure>

This sets up the base application for OIDC integration.

**6.4 Install OIDC dependencies**

Install the required OIDC libraries:

* `react-oidc-context`
* `oidc-client-ts`<br>

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FdOKegVwCviQyq0VnYc1Y%2Fimage.png?alt=media&amp;token=466020d1-86b6-4c9f-b39d-8385b6833433" alt=""><figcaption></figcaption></figure>

These libraries handle authentication flows and token management with Oten Identity.

**6.5 Configure Oten identity provider**<br>

1. Create a `.env` file at the project root.
2. Add the required environment variables:
   * Oten Authorization Domain
   * Client ID
3. In the Oten Developer Portal:
   * Open **Integration app**
   * Select your application
   * Open **Client details**
   * Copy the **Client ID** from the **Configure** tab

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FwRh1Q9ZOu7fuk71k7Mpx%2Fimage.png?alt=media&amp;token=4837b372-612a-4754-b59f-823c76e4abc3" alt=""><figcaption></figcaption></figure>

Note :

* Copy the **Client ID** from the **Configure** tab\ <br>

  <figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2Fn3PKgXDIZYcZuBGcJ7Ow%2Fimage.png?alt=media&amp;token=5dbbf15d-30b7-4687-a500-488d6644f897" alt=""><figcaption></figcaption></figure>

**6.6 Configure client URLs**

In **Client details → Settings**, configure the following:

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FFKHgVp4oQHMgVAxZRMx4%2Fimage.png?alt=media&amp;token=87314b61-0ec1-4684-9a06-f93611a5203d" alt=""><figcaption></figcaption></figure>

* **Redirect URIs**\
  Used after successful authentication\
  Example: `http://localhost:5173`
* **Logout URIs**\
  Used after user logout\
  Example: `http://localhost:5173`
* **Allow Origins (CORS)**\
  Required for browser-based requests\
  Example: `http://localhost:5173`

> Important\
> Only URLs listed here are allowed. Invalid or missing URLs will cause authentication failures.

**6.7 Create authentication components**

Create the following components in your React application:

* Login button
* Logout button
* User profile display

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FB4xbyk96Z5R21o2BufX9%2Fimage.png?alt=media&amp;token=a708fb3d-6072-4358-9af1-e11b85661424" alt=""><figcaption></figcaption></figure>

These components interact with Oten Identity via the OIDC context.

**6.8 Configure auth provider**

Wrap the application with the OIDC provider:

* Configure authority (Oten domain)
* Set client ID
* Define redirect and logout behavior
* Handle sign-in callback state cleanup

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FlUYlUW02h7V10ocnPmof%2Fimage.png?alt=media&amp;token=c2c2398a-42f5-415e-a7b9-d3673cb30db3" alt=""><figcaption></figcaption></figure>

This step enables authentication across the entire application.

**6.9 Apply styles (optional)**

Replace default styles with the provided CSS to match the example UI.

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2Fr7mApe4yTaRjdviGXJsz%2Fimage.png?alt=media&amp;token=20b3fcf1-a9f5-4d2d-813d-02ca78109b0a" alt=""><figcaption></figcaption></figure>

This step is optional and does not affect authentication logic.

**6.10 Update application entry point**

Update the main application component to:

* Render login/logout actions
* Display authenticated user information
* Handle loading and error states

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FgtGhQ5S6txbeCOZUbXtx%2Fimage.png?alt=media&amp;token=13d3a37f-280a-45d3-a8b6-5e67283b4693" alt=""><figcaption></figcaption></figure>

**6.11 Run the application**

Start the development server:

* Launch the app locally
* Open the browser at the configured origin
* Test the login and logout flows end-to-end

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FdzHD4ApT2oxJoRuLEXcc%2Fimage.png?alt=media&amp;token=f59661a1-c089-402f-af74-38b4a4a91ae2" alt=""><figcaption></figcaption></figure>

#### Step 7: Completion & next actions <a href="#step-7-completion-and-next-actions" id="step-7-completion-and-next-actions"></a>

After completing the Quick Start, a confirmation screen is displayed:

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FilhKwAd24Zxd5KpFbJlx%2Fimage.png?alt=media&amp;token=97d9d381-06e3-4b17-93e5-1f991d2f7b74" alt=""><figcaption></figcaption></figure>

You can now choose one of the following actions:

* **Go to Configure**\
  Continue configuring advanced client settings (SSO, MFA, policies)
* **Create another client**\
  Add an additional client (e.g. mobile app, another SPA)
* **Create another app**\
  Start a new integration application from scratch

#### Step 8: Additional configuration (optional) <a href="#step-8-additional-configuration-optional" id="step-8-additional-configuration-optional"></a>

For production or advanced use cases, further configuration is available under the **Configure** tab.

**8.1 Client credentials**

This section provides credentials required for SDK and API integration:

* **Client ID**\
  Used to identify your application when interacting with Oten services
* **Client secret**\
  Required for confidential client types

  Client secrets must remain private and must not be exposed publicly

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FtgNINtILswgqfVkWzCtG%2Fimage.png?alt=media&amp;token=779b90be-db82-4068-bf99-d28729d029c4" alt=""><figcaption></figcaption></figure>

**8.2 Configure client URIs**

Define the URLs used in authentication and authorization flows:

* **Redirect URIs**\
  Approved callback URLs after successful login\
  (Supports comma-separated or newline-separated entries)
* **Allow origins (CORS)**\
  Domains allowed to make cross-origin requests to Oten APIs\
  Redirect URIs are automatically included

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2Fi3ByKgUUEVNb8LEQIE9M%2Fimage.png?alt=media&amp;token=fd3a40c7-466b-46b4-bc8d-3c070a2e3c82" alt=""><figcaption></figcaption></figure>

&#x20;

**8.3 OpenID connect settings**

Configure OpenID Connect–related options, including:

* Back-Channel Logout URI
* Session and logout behavior
* Other OIDC-specific parameters

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2FePOH1V6p57nGLoNCg1sx%2Fimage.png?alt=media&amp;token=b4899675-6ed1-4d51-9ebc-20029abff41c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://40810359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNLjw84bGTVza9xA8NxxB%2Fuploads%2Fb1ex4voDzQ0N0BaUDb0D%2Fimage.png?alt=media&amp;token=f1f08a69-61e3-4e02-ac20-796cf9a155e6" alt=""><figcaption></figcaption></figure>
