By using whitelist api why i can login as administrator only but not with other user

by this code i can login with administrator and administrator credential by passing it in the parameter but i tried with other users its returns Invalid Credentials…how can i solve this.?

def login(usr, pwd):
    login_manager = frappe.auth.LoginManager()
    login_manager.authenticate(user=usr, pwd=pwd)
    login_manager.post_login()

    return 
{
    "message": "Invalid login credentials",
    "exception": "frappe.exceptions.AuthenticationError",
    "exc": "[\"Traceback (most recent call last):\\n  File \\\"apps/frappe/frappe/app.py\\\", line 69, in application\\n    response = frappe.api.handle()\\n  File \\\"apps/frappe/frappe/api.py\\\", line 54, in handle\\n    return frappe.handler.handle()\\n  File \\\"apps/frappe/frappe/handler.py\\\", line 45, in handle\\n    data = execute_cmd(cmd)\\n  File \\\"apps/frappe/frappe/handler.py\\\", line 83, in execute_cmd\\n    return frappe.call(method, **frappe.form_dict)\\n  File \\\"apps/frappe/frappe/__init__.py\\\", line 1599, in call\\n    return fn(*args, **newargs)\\n  File \\\"apps/library_management/library_management/api.py\\\", line 75, in login\\n    login_manager.authenticate(user=usr, pwd=pwd)\\n  File \\\"apps/frappe/frappe/auth.py\\\", line 254, in authenticate\\n    self.fail(\\\"Invalid login credentials\\\")\\n  File \\\"apps/frappe/frappe/auth.py\\\", line 307, in fail\\n    raise frappe.AuthenticationError\\nfrappe.exceptions.AuthenticationError\\n\"]"
}

@BalaV there is already login api in erpnext and it works just fine with all users .

1 Like

It returns session erpired for me.!

@BalaV try to logout and then lohin . and I suggest to use postman

1 Like

i will try it and thank you for your help :+1: