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

# Authorize

> Initiate OAuth authorization flow.

Generates an authorization URL for the specified provider and stores
the flow state in the database for CSRF protection.

Flow:
1. Resolve provider configuration (account override -> system fallback)
2. Generate state token (if not provided)
3. Store state in oauth_states table
4. Generate authorization URL via provider handler
5. Return URL and state



## OpenAPI

````yaml post /api/v1/auth/oauth/{provider_name}/authorize
openapi: 3.1.0
info:
  title: SnackBase
  description: Open-source Backend-as-a-Service (BaaS)
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/auth/oauth/{provider_name}/authorize:
    post:
      tags:
        - auth
      summary: Authorize
      description: |-
        Initiate OAuth authorization flow.

        Generates an authorization URL for the specified provider and stores
        the flow state in the database for CSRF protection.

        Flow:
        1. Resolve provider configuration (account override -> system fallback)
        2. Generate state token (if not provided)
        3. Store state in oauth_states table
        4. Generate authorization URL via provider handler
        5. Return URL and state
      operationId: authorize_api_v1_auth_oauth__provider_name__authorize_post
      parameters:
        - name: provider_name
          in: path
          required: true
          schema:
            type: string
            title: Provider Name
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OAuthAuthorizeRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthAuthorizeResponse'
        '400':
          description: Validation error
        '404':
          description: Provider not configured or account not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    OAuthAuthorizeRequest:
      properties:
        account:
          anyOf:
            - type: string
            - type: 'null'
          title: Account
          description: Account identifier (slug or ID)
        account_name:
          anyOf:
            - type: string
              maxLength: 255
              minLength: 1
            - type: 'null'
          title: Account Name
          description: Display name for the new account (used when creating a new account)
        redirect_uri:
          type: string
          title: Redirect Uri
          description: URI to redirect to after OAuth completion
        state:
          anyOf:
            - type: string
            - type: 'null'
          title: State
          description: Optional state for CSRF (auto-generated if missing)
      type: object
      required:
        - redirect_uri
      title: OAuthAuthorizeRequest
      description: Request body for starting an OAuth flow.
    OAuthAuthorizeResponse:
      properties:
        authorization_url:
          type: string
          title: Authorization Url
          description: URL to redirect the user to
        state:
          type: string
          title: State
          description: The state token used for this flow
        provider:
          type: string
          title: Provider
          description: The provider name
      type: object
      required:
        - authorization_url
        - state
        - provider
      title: OAuthAuthorizeResponse
      description: Response for OAuth authorization initiation.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````