1

Currently, I am using this type of docstring with Flassger which works fine:

"""End Point to create something
  ---
  parameters:
    - name: body
      in: body
      type: string
      required: true
    - name: token
      in: header
      description: an authorization header
      required: true
      type: string
  responses:
    200:
      description: Some description
  """

And I am able to send the request from ui like this:

enter image description here

But I need to make the token parameter global on this page, so that the user only need to fill this just once. What do I need to do to achieve that?

1 Answer 1

1

All you need to do is define the authorization token in the api definitions. Try something like this:

  securityDefinitions:
  Token:
   type: apiKey
   name: Token
   in: header

And then put this code in the endpoint you want to secure with the token:

 security:
 -Token: []

In your example:

  parameters:
  - name: body
   in: body
   type: string
   required: true
   security
   - Token:[]
   responses:
     200:
      description: Some description

If you want to secure all the endpoints with the token do like this:

securityDefinitions:
  Token:
   type: apiKey
   name: Token
   in: header
security
   - Token:[]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.