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

# OAuth callback handler

> Handle OAuth callback from provider. Exchanges authorization code for access token, fetches user info, creates or finds user, and redirects to app with a magic link token for authentication.



## OpenAPI

````yaml /swagger.json get /v1/auth/{app_id}/oauth/callback
openapi: 3.0.1
info:
  title: Scute API
  version: v1
  description: API for managing users in Scute applications
servers:
  - url: https://{defaultHost}
    variables:
      defaultHost:
        default: api.scute.io
  - url: http://localhost:3333
    description: Development server
security:
  - apiSecret: []
    userAccess: []
paths:
  /v1/auth/{app_id}/oauth/callback:
    parameters:
      - name: app_id
        in: path
        required: true
        description: App ID
        schema:
          type: string
      - name: code
        in: query
        description: OAuth authorization code
        required: true
        schema:
          type: string
      - name: state
        in: query
        description: OAuth state parameter
        required: true
        schema:
          type: string
    get:
      tags:
        - OAuth
      summary: OAuth callback handler
      description: >-
        Handle OAuth callback from provider. Exchanges authorization code for
        access token, fetches user info, creates or finds user, and redirects to
        app with a magic link token for authentication.
      operationId: handleOAuthCallback
      responses:
        '302':
          description: redirect to app with magic link
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    description: >-
                      Redirect URL to app with magic link token parameter
                      (sct_oauth)
                description: Redirects to the app's login URL with magic link token
        '400':
          description: invalid identifier
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    example: Identifier invalid
                  error_code:
                    type: string
                    example: invalid_identifier
        '500':
          description: oauth authentication failed
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: OAuth authentication failed
                  error:
                    type: string
                    description: Error details
components:
  securitySchemes:
    apiSecret:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API Secret token
    userAccess:
      type: apiKey
      name: X-Authorization
      in: header
      description: User Access token

````