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

# Generate OAuth2 client credentials token

> Generates an OAuth2 access token using the Client Credentials flow.



## OpenAPI

````yaml /content/developer-guide/api-reference/openapi_v1.json post /oauth2/token
openapi: 3.1.0
info:
  title: API - V1
  version: 1.0.0
servers:
  - url: https://api.mycreditapp.ai/v1-beta
security: []
paths:
  /oauth2/token:
    post:
      tags:
        - OAuth
      summary: Generate OAuth2 client credentials token
      description: Generates an OAuth2 access token using the Client Credentials flow.
      operationId: create_api_client_tokens_oauth2_token_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OauthApiClientCredentials'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OauthApiClientTokens'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                detail:
                  - loc: []
                    msg: The client authentication failed!
                    type: oauth
                    code: oauth_invalid_client_credentials
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                detail:
                  - loc: []
                    msg: The client is not authorized to perform this action!
                    type: oauth
                    code: oauth_unauthorized_client
        '413':
          description: Request Entity Too Large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                detail:
                  - loc: []
                    msg: The request is too large!
                    type: request
                    code: request_too_large
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                detail:
                  - loc:
                      - string
                      - 0
                    msg: string
                    type: string
                    code: validation_error
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                detail:
                  - loc: []
                    msg: Too many requests! Try later
                    type: oauth
                    code: oauth_service_rate_limit
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                detail:
                  - loc: []
                    msg: Error processing request, please try later!
                    type: try_later
                    code: internal_conflict_error
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                detail:
                  - loc: []
                    msg: The oauth service unavailable right now. Please try later!
                    type: oauth
                    code: oauth_service_unavailable
                  - loc: []
                    msg: Service is under maintenance, please try later!
                    type: maintanance
                    code: service_under_maintenance
components:
  schemas:
    OauthApiClientCredentials:
      properties:
        client_id:
          type: string
          maxLength: 128
          minLength: 1
          title: Client Id
          description: Unique identifier of the API client issued during registration
          examples:
            - 5gtyhu78ujmlko90iikmjunbh
            - 1example23456789abcdefghijk
        client_secret:
          type: string
          maxLength: 64
          minLength: 1
          format: password
          title: Client Secret
          description: >-
            Secret key associated with the client_id, used to authenticate the
            client
          writeOnly: true
          examples:
            - abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/=
      type: object
      required:
        - client_id
        - client_secret
      title: OauthApiClientCredentials
    OauthApiClientTokens:
      properties:
        access_token:
          type: string
          minLength: 1
          title: Access Token
          description: OAuth2 access token that must be used to authorize API requests
          examples:
            - eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        expires_in:
          type: integer
          title: Expires In
          description: Lifetime of the access token in seconds
          examples:
            - 3600
            - 7200
      type: object
      required:
        - access_token
        - expires_in
      title: OauthApiClientTokens
    APIError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ErrorItem'
          type: array
          title: Detail
          description: >

            List of returned errors.

            **All unsuccessful error codes except code `422` can only contain 1
            element in the list**.
      type: object
      required:
        - detail
      title: APIError
    ErrorItem:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Loc
          description: |

            Shows the dynamic location of the current error.
            If an empty array is returned, the error is static.
          examples:
            - - body
              - date_field
              - 0
            - - header
              - Authorization
        msg:
          type: string
          title: Msg
          description: |

            A human-readable message providing more details about the error.
          examples:
            - Token is required!
            - Invalid token!
        type:
          type: string
          title: Type
          description: >

            A string indicating the type of error.

            **The list is not fixed, so it's necessary to pay attention to the
            possible type for a specific error**.
          examples:
            - token
            - request
            - try_later
        code:
          type: string
          title: Code
          description: >

            Unique text error code identifying the error.

            **The list is not fixed, so it's necessary to pay attention to the
            possible code for a specific error**.
          examples:
            - token_required
            - invalid_token
            - access_denied
      type: object
      required:
        - loc
        - msg
        - type
        - code
      title: ErrorItem

````