> ## Documentation Index
> Fetch the complete documentation index at: https://docs.insforge.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Sign in with a native provider ID token

> Authenticate a user using an ID token obtained from Google or Apple's native SDK.
Apple requests require the original raw nonce whose lowercase SHA-256 hex digest was
attached to the native authorization request. Apple token audiences are validated only
against the project's configured clientId and nativeClientIds; callers cannot select a
trusted audience.




## OpenAPI

````yaml https://raw.githubusercontent.com/InsForge/InsForge/main/openapi/auth.yaml post /api/auth/id-token
openapi: 3.0.3
info:
  title: Insforge Authentication API
  version: 2.0.0
  description: Authentication endpoints with separated auth and profile tables
servers: []
security: []
paths:
  /api/auth/id-token:
    post:
      tags:
        - Client
      summary: Sign in with a native provider ID token
      description: >
        Authenticate a user using an ID token obtained from Google or Apple's
        native SDK.

        Apple requests require the original raw nonce whose lowercase SHA-256
        hex digest was

        attached to the native authorization request. Apple token audiences are
        validated only

        against the project's configured clientId and nativeClientIds; callers
        cannot select a

        trusted audience.
      parameters:
        - name: client_type
          in: query
          schema:
            type: string
            enum:
              - web
              - mobile
              - desktop
              - server
            default: web
          description: >
            Client type determines how refresh tokens are returned:

            - web: Refresh token stored in httpOnly cookie, csrfToken returned
            in response

            - mobile/desktop/server: refreshToken returned directly in response
            body
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/GoogleIdTokenSignInRequest'
                - $ref: '#/components/schemas/AppleIdTokenSignInRequest'
              discriminator:
                propertyName: provider
                mapping:
                  google:
                    $ref: '#/components/schemas/GoogleIdTokenSignInRequest'
                  apple:
                    $ref: '#/components/schemas/AppleIdTokenSignInRequest'
      responses:
        '200':
          description: Sign-in successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  user:
                    $ref: '#/components/schemas/UserResponse'
                  accessToken:
                    type: string
                  csrfToken:
                    type: string
                    nullable: true
                    description: >-
                      CSRF token for use with refresh endpoint (web clients
                      only)
                  refreshToken:
                    type: string
                    nullable: true
                    description: >-
                      Refresh token for mobile/desktop/server clients (null for
                      web clients)
        '400':
          description: Invalid request - unsupported provider or missing token
        '401':
          description: Invalid or expired ID token
components:
  schemas:
    GoogleIdTokenSignInRequest:
      type: object
      required:
        - provider
        - token
      properties:
        provider:
          type: string
          enum:
            - google
        token:
          type: string
          minLength: 1
          description: Raw Google ID token
    AppleIdTokenSignInRequest:
      type: object
      additionalProperties: false
      required:
        - provider
        - token
        - nonce
      properties:
        provider:
          type: string
          enum:
            - apple
        token:
          type: string
          minLength: 1
          description: Raw identityToken from ASAuthorizationAppleIDCredential
        nonce:
          type: string
          minLength: 1
          maxLength: 255
          description: >-
            Original raw nonce whose lowercase SHA-256 hex digest was attached
            to ASAuthorizationAppleIDRequest
        name:
          type: string
          minLength: 1
          maxLength: 100
          description: Optional display name returned on first Apple authorization
    UserResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        email:
          type: string
          format: email
        profile:
          type: object
          nullable: true
          additionalProperties: true
          description: User profile data (name, avatar_url, and custom fields)
          properties:
            name:
              type: string
            avatar_url:
              type: string
              format: uri
        metadata:
          type: object
          nullable: true
          additionalProperties: true
          description: System metadata (device ID, login IP, etc.)
        emailVerified:
          type: boolean
        providers:
          type: array
          items:
            type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time

````