Search code examples
openapiswagger-2.0swagger-editorinsomnia

How to pass token and refresh token as Authorization in the header using OpenApi 2.O?


I'm new to OpenApi, I'm using Insomnia and I'm trying to pass Authorization: { "token": "dehxsasn8478snsajsx", "refreshToken": "cddjnc5156" } in the header but Header parameters named Accept, Content-Type, and Authorization are not allowed so I have to use a security scheme for that purpose but which security scheme should I go for and how to pass this structure(Authorization: { "token": "dehxsasn8478snsajsx", "refreshToken": "cddjnc5156" }) in the header is what's driving me crazy. Here's what I'm trying ..I know it's wrong but i'm stuck

securitySchemes:
    ApiKeyAuth:
        type: apiKey
        in: header
        name: Authorization
        content:
           application/json:
             schema:
               type: object
               properties:
                 token:
                   type: string
                   example: "ab"
                 refreshToken:
                   type: string
                   example: "djdjsn"

Solution

  • Use apiKey as security schema

    securitySchemes:
        apiKey:
          type: apiKey
          in: header
          name: Authorization
    

    and in the path add

    security:
            - apiKey: []
    

    and in the header pass

    { "token": "dehxsasn8478snsajsx", "refreshToken": "cddjnc5156" }
    

    as the string.