Custom Login Api Method

Hi,

how can i call / use /api/method/login method in my custom app,
i am trying to make custom login method, which will return special result.

I think this discussion will helpful to you.

Hi Mahesh, I used similar but getting error.

login_manager = LoginManager()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/auth.py", line 104, in __init__
if frappe.local.form_dict.get('cmd')=='login' or frappe.local.request.path=="/api/method/login":
  File "/home/frappe/frappe-bench/env/lib/python3.6/site-packages/werkzeug/local.py", line 74, in __getattr__
raise AttributeError(name)
AttributeError: request

my code :

@frappe.whitelist(allow_guest=True)
def login_instructor(usr, pwd):
	login_manager = LoginManager()
	login_manager.authenticate(usr,pwd)
	login_manager.post_login()
	if frappe.response['message'] == 'Logged In':
		instructor = frappe.db.get_value("Instructor", {"user": login_manager.user}, "name")
		if instructor: return instructor
	return "No Instructor Found."

It worked actually, it was just not working with bench execute.