openapi: 3.1.0
info:
  title: Auth API
  version: v2
servers:
  - url: https://api-ext-sboxmeta.partners.spotnana.com
    description: Sandbox URL
security: []
components:
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
  responses:
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  schemas:
    ErrorParameter:
      type: object
      title: ErrorParameter
      description: Error parameter
      properties:
        name:
          type: string
          description: Parameter name
        value:
          type: string
          description: Parameter value
    ErrorResponse:
      type: object
      properties:
        debugIdentifier:
          type: string
          description: Link to debug the error internally.
        errorMessages:
          type: array
          items:
            type: object
            properties:
              errorCode:
                type: string
                description: Error code to identify the specific errors.
              message:
                type: string
                description: Message containing details of error.
              errorParameters:
                type: array
                description: Error message parameters.
                items:
                  $ref: '#/components/schemas/ErrorParameter'
              errorDetail:
                type: string
                description: More details about the error.
    OAuthTokenRequest:
      type: object
      title: OAuthTokenRequest
      x-ignore-naming-case: true
      required:
        - grant_type
        - client_id
        - client_secret
      properties:
        grant_type:
          type: string
          description: >-
            Supported values are `client_credentials` and
            `urn:ietf:params:oauth:grant-type:token-exchange`.
        client_id:
          type: string
          description: Identifier for the API user.
        client_secret:
          type: string
          description: Password
        audience:
          type: string
          description: Identifies the API being accessed in Spotnana.
          example: https://apis.spotnana.com/v2
        subject_token:
          type: string
          description: >
            A security token that represents the identity of the entity on whose
            behalf the request 

            is being made.
        subject_token_type:
          type: string
          description: >
            Indicates the type of the `subject_token` used for token exchange. 

            This field supports the valid types as per the OAUTH 2.0 security
            framework.
        scope:
          type: string
          description: >
            The list of space-delimited, case-sensitive strings, as defined in
            Section 3.3 of 

            RFC6749 OAuth 2.0 framework, that allow the client to specify the
            desired scope of the requested security 

            token in the context of the service or resource where the token will
            be used.
    OAuthTokenResponse:
      type: object
      title: OAuthTokenResponse
      required:
        - access_token
        - token_type
      x-ignore-naming-case: true
      properties:
        access_token:
          type: string
          description: >-
            The token to be used in subsequent API calls made to the Spotnana
            platform.
        expires_in:
          type: integer
          description: The length of time (in seconds) for which the access token is valid.
          format: int32
        token_type:
          type: string
          description: >
            A case-insensitive value specifying the method of using the access
            token issued, as 

            specified in Section 7.1 of [RFC6749].
          example: Bearer
        refresh_token:
          type: string
          description: >
            Used to fetch a new access token when the existing token expires.

            The refresh token will not be available if the `grant_type` is
            `client_credentials`.
        scope:
          type: string
          description: >
            The list of space-delimited, case-sensitive strings, as defined in
            Section 3.3 of 

            [RFC6749], that allow the client to specify the desired scope of the
            requested security 

            token in the context of the service or resource where the token will
            be used.
tags:
  - name: Authentication
    description: Authentication APIs for user login, logout, and token management
paths:
  /v2/auth/oauth2-token:
    post:
      tags:
        - Authentication
      summary: Get oauth2 token
      description: Get oauth2 token using the client credentials.
      operationId: fetchOauth2Token
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/OAuthTokenRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OAuthTokenResponse'
        '403':
          $ref: '#/components/responses/Forbidden'
