Skip to main content

StartSocialRedirectQueryDTO

Package: @nauth-toolkit/core Type: DTO (Request Query Parameters)

Query DTO for initiating a backend-first OAuth redirect flow where the provider redirects back to the backend callback endpoint. Used with SocialRedirectHandler.

import { StartSocialRedirectQueryDTO } from '@nauth-toolkit/nestjs';

Properties

PropertyTypeRequiredDescription
action'login' | 'link'NoRedirect action type. login for standard social login/signup, link to link social account to existing user. Default: login
appStatestringNoOpaque, non-secret state to round-trip back to the frontend. Max 2000 characters. Trimmed.
returnTostringNoFrontend path or absolute URL to redirect to after authentication completes. Max 2048 characters. Trimmed. Default: /auth/callback
oauthParamsstringNoAdditional OAuth parameters to pass to the provider. Passed as JSON string in query parameter. These parameters override config defaults and are appended to the provider's authorization URL. Max 2000 characters. Trimmed. Used for provider-specific customization.

OAuth Parameters

The oauthParams property allows per-request customization of the OAuth flow. Pass provider-specific parameters as a JSON string. These override any defaults set in the backend configuration. The handler parses the JSON string automatically; the consumer controller passes the DTO as-is to SocialRedirectHandler.start(provider, dto).

Common Parameters by Provider

Google:

  • prompt: 'select_account', 'consent', 'none'
  • hd: Restrict to Google Workspace domain
  • login_hint: Pre-fill email address
  • include_granted_scopes: 'true' for incremental auth

Facebook:

  • auth_type: 'reauthenticate', 'rerequest'
  • display: 'page', 'popup', 'touch'
  • auth_nonce: For replay attack prevention

Apple:

  • nonce: For ID token validation

Example

Basic Request

GET /auth/social/google/redirect?returnTo=/auth/callback&appState=user123&action=login HTTP/1.1
Host: api.example.com

With OAuth Parameters (Force Google Account Chooser)

GET /auth/social/google/redirect?returnTo=/dashboard&oauthParams={"prompt":"select_account"} HTTP/1.1
Host: api.example.com

Multiple OAuth Parameters

GET /auth/social/google/redirect?returnTo=/dashboard&oauthParams={"prompt":"select_account consent","hd":"company.com"} HTTP/1.1
Host: api.example.com

Used By