openapi: 3.0.1
info:
  version: '1.0.0'
  title: Identity Provider API
  description: This API helps you to generate the access token for OAuth 2.0 using valid credentials.
  contact:
    name: API Support
    email: devportal.support@michelin.com
    url: 'https://developer.michelin.com/en/contact'
servers:
  - url: https://api.michelin.com
    description: prod


paths:
  /idp/v1/internal/oauth/token/accesstoken:
    post:
      tags:
        - Oauth Token
      parameters:
        - name: grant_type 
          in: query
          description: Grant type of Oauth
          required: true
          schema:
              type: string
              enum: [client_credentials]
      requestBody:
        description: Generate access token for Oauth Authentication
        content:
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/OauthRequest'
        required: true
      responses:
        '200':
          description: 'Successful Oauth Response'
          content:
            application/json:
              schema:
                "$ref": "#/components/schemas/SuccessResponse"
        '401':
          description: 'Successful Oauth Response'
          content:
            application/json:
              schema:
                "$ref": "#/components/responses/401"
        '500':
          description: 'Successful Oauth Response'
          content:
            application/json:
              schema:
                "$ref": "#/components/responses/internal_error_locale"
         
        '400':
          description: 'Successful Oauth Response'
          content:
            application/json:
              schema:
                "$ref": "#/components/responses/400"

      summary: Generate Oauth Token
 
components:

  parameters:
    ApiKey:
      schema:
        type: string
      in: header
      name: apikey
      description: Custom header for API gateway analytics
      required: true
  schemas:
    OauthRequest:
      required:
        - client_id
        - client_secret
      type: object
      properties:
        client_id:
          type: integer
          format: int64
          example: a578tj9675lkl65nb4
        client_secret:
          type: integer
          format: k975hu429h3479hvbjl
          example: 10255532453635
        scope:
          type: string
          example: ai-dot-image-recoginition
        
    SuccessResponse:
      type: object
      properties:
        refresh_token_expires_in:
          type: string
        api_product_list:
          type: string
        organization_name:
          type: string
        developer.email:
          type: string
        token_type:
          type: string
        issued_at:
          type: string
        client_id:
          type: string
        access_token:
          type: string
        application_name:
          type: string
        scope:
          type: string
        expires_in:
          type: string
        refresh_count:
          type: string
        status:
          type: string


  responses:
    bad_request:
      description: Bad Request
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              code:
                type: string
                example: "BAD_USER"
              raison:
                type: string
                example: "Cannot find any active domain associated to user"
    internal_error_locale:
      description: 'Missings fields or Internal Error'
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              code:
                type: string
                example: "Internal Error"
              raison:
                type: string
                example: "Error: Missing fields [locale] in request"
    '401':
      description: Unauthorised error
      content:
        application/json:
          example: |-
            {
              "ErrorCode": "invalid_client",
              "Error": "ClientId is Invalid"
            }

    '400':
      description: Bad Request
      content:
        application/json:
          example: |-
            {
              "ErrorCode": "invalid_request",
              "Error": "Required param : grant_type"
            }
    '500':
      description: Internal server error   
      content:
        application/json:
          example: |-
            {
              "ErrorCode": "Internal server error",
              "Error": ""
            }

     