code: def login():
      
      try:
          username = request.form.get("username")
          password = request.form.get("password")
  
          user = authenticate(username, password)
          if not user:
              raise Exception("User not found!")
  
          resp = jsonify({"message": "User authenticated"})
          resp.status_code = 200
  
          access_token = jwt.jwt_encode_callback(user)
  
          # add token to response headers - so SwaggerUI can use it
          resp.headers.extend({'jwt-token': access_token})
  
      except Exception as e:
          resp = jsonify({"message": "Bad username and/or password"})
          resp.status_code = 401
  
      return resp
docs: User authenticate method.
      ---
      description: Authenticate user with supplied credentials.
      parameters:
        - name: username
          in: formData
          type: string
          required: true
        - name: password
          in: formData
          type: string
          required: true
      responses:
        200:
          description: User successfully logged in.
        400:
          description: User login failed.