myapi/auth/views.py
def login():
    """Authenticate user and return token
       ---
       tags:
         - Login
    """
    # if not request.is_json:
    #     return jsonify({"msg": "Missing JSON in request"}), 400
    username = request.form.get('username', None)
    password = request.form.get('password', None)
    if not username or not password:
        return jsonify({"msg": "Missing username or password"}), 400

    user = User.query.filter_by(username=username).first()
    if user is None or not pwd_context.verify(password, user.password):
        return jsonify({"msg": "Bad credentials"}), 400

    access_token = create_access_token(identity=user.id)
    refresh_token = create_refresh_token(identity=user.id)

    ret = {
        'access_token': access_token,
        'refresh_token': refresh_token
    }
    return jsonify(ret), 200
Authenticate user and return token
       ---
       tags:
         - Login
    
Authenticate user and return token
tags:
Login
Authenticate user and return token tags : Login
def login():
    username = request.form.get('username', None)
    password = request.form.get('password', None)
    if not username or not password:
        return jsonify({"msg": "Missing username or password"}), 400
    user = User.query.filter_by(username=username).first()
    if user is None or not pwd_context.verify(password, user.password):
        return jsonify({"msg": "Bad credentials"}), 400
    access_token = create_access_token(identity=user.id)
    refresh_token = create_refresh_token(identity=user.id)
    ret = {
        'access_token': access_token,
        'refresh_token': refresh_token
    }
    return jsonify(ret), 200
def login ( ) : username = request . form . get ( 'username' , None ) password = request . form . get ( 'password' , None ) if not username or not password : return jsonify ( { "msg" : "Missing username or password" } ) , 400 user = User . query . filter_by ( username = username ) . first ( ) if user is None or not pwd_context . verify ( password , user . password ) : return jsonify ( { "msg" : "Bad credentials" } ) , 400 access_token = create_access_token ( identity = user . id ) refresh_token = create_refresh_token ( identity = user . id ) ret = { 'access_token' : access_token , 'refresh_token' : refresh_token } return jsonify ( ret ) , 200
Authenticate user and return token
tags:
 Login
Authenticate user and return token tags : Login
"""Authenticate user and return token
       ---
       tags:
         - Login
    """ # if not request.is_json: #     return jsonify({"msg": "Missing JSON in request"}), 400