Background
OAuth (Open Authorization) is an open-standard framework for access delegation, allowing applications to securely access a user’s protected resources without exposing their login credentials. By keeping passwords private and limiting access to sensitive information, OAuth improves both security and access management across web, mobile, and desktop applications. OAuth 2.0, the current and most widely adopted version, expands upon the original protocol to support APIs, mobile apps, and connected devices, offering multiple authorization flows tailored to different application types. When embedding Corti Assistant in your application (via iFrame/WebView), it’s important to use the right OAuth2 grant type that supports user-based authentication. This guide explains the OAuth flows that work with embedded Corti Assistant, focusing on user-based authentication methods that are suitable for interactive scenarios.Supported OAuth grant types for Embedded Corti Assistant
The following OAuth flows support user-based authentication and can be used with embedded Corti Assistant. Client credentials grant is NOT supported as it does not provide user context.1. Authorization code flow with PKCE (recommended)
Best for: Native apps, single-page apps, or any browser-based integration where a user is present. Why: This flow is secure, interactive, and doesn’t require a client secret (ideal for public clients). Proof Key for Code Exchange (PKCE) protects against code interception attacks. How it works:- Your app redirects the user to Corti’s OAuth2 authorization server.
- The user logs in and grants permission.
- Corti redirects back with an authorization code.
- Your app exchanges the code (with the PKCE verifier) for an access token.
- Secure and suitable for embedded web apps.
- No client secret is required.
- Enforces user interaction.
Code sample:
Code sample:
- Using Corti JS SDK
- Using Fetch
- C#
Step 1: Generate Authorization URL (Frontend)
Step 2: Handle the Callback and Exchange Code for Tokens
2. Authorization code flow (without PKCE)
Best for: Server-side web applications embedding Corti Assistant where the client secret can be safely stored on the backend. Why: Similar to PKCE, but requires storing a client secret — which is not safe in public or browser-based clients. Key Concerns:- Unsafe for apps where the frontend or iFrame can be inspected.
- Only acceptable in secure backend environments where the client secret can be protected.
Code sample:
Code sample:
- Using Corti JS SDK
- Using Fetch
- C#
Step 1: Create Authorization URL
Step 2: Handle the Callback and Exchange Code for Tokens
Step 3: Exchange Code for Access Token (Backend)
Requirements:
- Must use HTTPS for
redirect_uri - Your
client_secretmust not be exposed to the frontend - The code returned is valid for one use and short-lived
3. Resource Owner Password Credentials (ROPC) grant (use with caution)
Best for: Controlled environments embedding Corti Assistant with trusted clients (e.g., internal tools). Why: Allows username/password login directly in the app — but bypasses the authorization server UI. Risks:- Trains users to enter passwords into third-party apps.
- Easy to misuse, violates best practices.
- Only viable where UI constraints prevent redirecting (e.g., native kiosk apps without browsers).
Code sample:
Code sample:
- Using Corti JS SDK
- Using Fetch
- C#
Final guidance
Pick the flow that matches your interaction model as offered above. See further details and contact us for support here. What to use when:- For embedded Corti Assistant (e.g., in an iFrame/WebView):
Use Authorization Code Flow with PKCE to authenticate the end user securely. This is the recommended flow for most embedded integrations. - For server-side integrations where you can securely store a client secret:
Authorization Code Flow (without PKCE) may be used, but ensure the client secret is never exposed to the frontend. - For constrained environments without redirect capabilities:
ROPC may be used with caution, but only in trusted internal environments. - Client Credentials is NOT supported — it does not provide user context and will not work with embedded Corti Assistant.