Maintaining auth with frappe-client

I’m working with the api with python, using frappe-client.

Based on the example I run

client = FrappeClient("http://localhost:8080", "Administrator", "somepassword")

And get no errors (which seems to mean things are ok).

For testing I also tried client.login("Administrator", "somepassword") it returns:

{u'full_name': u'Administrator',
u'home_page': u'/desk',
u'message': u'Logged In'}

So I think the login is working.

But when I try to get a document (ie: client.get_doc("Customer")), it spews out an entire 403 - permission denied page. It seems like it’s dropping the session for the next command.

Thanks for any help!

Hi @jasonh,

I trust you are following the instructions on https://github.com/frappe/frappe-client

The connection will remain with the object, in this case client. When trying to get a customer record, you will need to specify which record to get…

customer = client.get_doc("Customer", customer_name['name'])

E.g.

customer = client.get_doc("Customer", "Mycustomer")
sales_invoice = client.get_doc("Sales Invoice", "SINV-00021")

Hope this helps.

1 Like

Just for future reference, it appears my issue was related to using ERPNext in a VM via NAT. Once I did an install to something that had it’s own IP address, API access worked fine. Thanks for the response @lasalesi