PetroGromovo
1 week ago

How to keep access_token parameter from login for next post requests

Posted 1 week ago by PetroGromovo

Hello, In swagger With api 3 version I have login described as :

  /login:
    post:
      tags:
        - user login
      summary: User login

      responses:
        '200':
          description: Successful login
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserLogin'
        '400':
          description: Invalid login

      operationId: postLogin
      requestBody:
        description: Login user fields
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                email:
                  type: string
                  default: [email protected]
                password:
                  type: string
                  default: 111111
              required:
                - email
                - password

and if login is successfull amonth returned data I have access_token field.

With schema described as :

components:
  schemas:


    UserLogin:
      properties:
        access_token:
          type: string
        user:
          $ref: '#/components/schemas/UserLogin'
        token_type:
          type: string
        user_avatar_path:
          type: string
        usersGroups:
          type: array
        expires_in:
          type: integer

I need to use this access_token value for next post requests to get access to authorized pages.

How can I do this in swagger. Seems I can not copypaste access_token value from login requeest for my post requests, asthey do not access_token parameter ?

Thanks!

Please sign in or create an account to participate in this conversation.