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

# Get Access Token

> Exchange authorization code for access token, or obtain access token using client credentials.

**Supported Grant Types:**
- `authorization_code`: Exchange authorization code from login flow (requires Basic Auth with client_id:client_secret)
- `client_credentials`: Server-to-server authentication for POS systems (requires Basic Auth)
- `refresh_token`: Refresh an expired access token

**Authentication:**
All token requests require HTTP Basic Authentication with base64-encoded `client_id:client_secret` in the Authorization header.




## OpenAPI

````yaml /authentication.openapi.yaml post /connect/token
openapi: 3.0.1
info:
  title: ClearLine Authentication API
  description: >-
    OAuth2 authentication endpoints for ClearLine Marketing Platform. Supports
    both Client Credentials flow (for POS server-to-server) and Authorization
    Code flow with PKCE (for user authentication).
  version: v1
servers:
  - url: https://logintest.clearline.me
    description: Test Environment - Identity Server
  - url: https://logindemo.clearline.me
    description: Demo Environment - Identity Server
  - url: https://login.clearline.me
    description: Production Environment - Identity Server
security: []
paths:
  /connect/token:
    post:
      tags:
        - Authentication
      summary: Get Access Token
      description: >
        Exchange authorization code for access token, or obtain access token
        using client credentials.


        **Supported Grant Types:**

        - `authorization_code`: Exchange authorization code from login flow
        (requires Basic Auth with client_id:client_secret)

        - `client_credentials`: Server-to-server authentication for POS systems
        (requires Basic Auth)

        - `refresh_token`: Refresh an expired access token


        **Authentication:**

        All token requests require HTTP Basic Authentication with base64-encoded
        `client_id:client_secret` in the Authorization header.
      operationId: OAuth2_Token
      parameters:
        - name: Authorization
          in: header
          required: true
          description: >-
            Basic authentication header: "Basic
            {Base64(client_id:client_secret)}"
          schema:
            type: string
          example: Basic Y2xvdmVyLWNtYy1tb2JpbGU6Y2xpZW50U2VjcmV0IQ==
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              oneOf:
                - $ref: '#/components/schemas/AuthorizationCodeTokenRequest'
                - $ref: '#/components/schemas/ClientCredentialsTokenRequest'
                - $ref: '#/components/schemas/RefreshTokenRequest'
            examples:
              authorizationCode:
                summary: Authorization Code Exchange (Mobile/PKCE)
                value:
                  grant_type: authorization_code
                  code: authorization_code_from_callback
                  redirect_uri: clover://auth-callback
                  code_verifier: original_code_verifier_string
              clientCredentials:
                summary: Client Credentials (POS Integration)
                value:
                  grant_type: client_credentials
                  scope: pos_integration
              refreshToken:
                summary: Refresh Token
                value:
                  grant_type: refresh_token
                  refresh_token: your_refresh_token
      responses:
        '200':
          description: Successful token response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
              examples:
                authCodeSuccess:
                  summary: Authorization Code Success
                  value:
                    access_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
                    token_type: Bearer
                    expires_in: 3600
                    refresh_token: df8a2f3e...
                    scope: clearline_api
                clientCredsSuccess:
                  summary: Client Credentials Success
                  value:
                    access_token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
                    token_type: Bearer
                    expires_in: 3600
                    scope: pos_integration
        '400':
          description: Bad request - invalid grant or parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - invalid client credentials in Basic Auth header
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    AuthorizationCodeTokenRequest:
      type: object
      required:
        - grant_type
        - code
        - redirect_uri
        - code_verifier
      properties:
        grant_type:
          type: string
          enum:
            - authorization_code
          description: Must be "authorization_code"
        code:
          type: string
          description: The authorization code received from the callback
        redirect_uri:
          type: string
          description: The same redirect_uri used in the authorization request
          example: clover://auth-callback
        code_verifier:
          type: string
          description: >-
            The original code_verifier string used to generate code_challenge
            (43-128 characters)
      description: >-
        Token request for Authorization Code flow with PKCE. Requires Basic Auth
        header with client_id:client_secret.
    ClientCredentialsTokenRequest:
      type: object
      required:
        - grant_type
      properties:
        grant_type:
          type: string
          enum:
            - client_credentials
          description: Must be "client_credentials"
        scope:
          type: string
          description: Requested scopes - typically "pos_integration" for POS systems
          example: pos_integration
      description: >-
        Token request for Client Credentials flow (POS server-to-server).
        Requires Basic Auth header with client_id:client_secret.
    RefreshTokenRequest:
      type: object
      required:
        - grant_type
        - refresh_token
      properties:
        grant_type:
          type: string
          enum:
            - refresh_token
          description: Must be "refresh_token"
        refresh_token:
          type: string
          description: The refresh token from previous token response
      description: >-
        Token request to refresh an expired access token. Requires Basic Auth
        header with client_id:client_secret.
    TokenResponse:
      type: object
      properties:
        access_token:
          type: string
          description: >-
            The JWT access token to use in API requests via "Authorization
            Bearer {token}" header
          example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        token_type:
          type: string
          description: Token type - always "Bearer"
          example: Bearer
        expires_in:
          type: integer
          description: Token lifetime in seconds (typically 3600 = 1 hour)
          example: 3600
        refresh_token:
          type: string
          description: >-
            Refresh token to obtain new access token when current expires (not
            provided for client_credentials grant)
          nullable: true
          example: df8a2f3e...
        scope:
          type: string
          description: The scopes granted by this token
          example: clearline_api
    ErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Error code (e.g., invalid_grant, invalid_client, invalid_request)
          example: invalid_grant
        error_description:
          type: string
          description: Human-readable error description
          example: The authorization code is invalid or expired

````