ERPNEXT step does not authenticate correctly

I have successfully connected up ERPNEXT.

In steps.erpnext.debug.config object can see that i have the correct url, username and password

aync (events,steps,auth) ==> {
return await require("@pipedreamhq/platform").axios(this, {
url: ${auths.erpnext.base_url}/api/method/frappe.auth.get_logged_user,
auth: {
username: ${auths.erpnext.api_key},
password: ${auths.erpnext.api_secret},

However when i create a step that uses ERPNEXT i get authentication errors.

ErrorRequest failed with status code 401

“exc_type”: “AuthenticationError”,
“exc”: “[“Traceback (most recent call last):\n File \”/home/frappe/frappe-bench/apps/frappe/frappe/\”, line 59, in application\n frappe.api.validate_auth()\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/\", line 173, in validate_auth\n validate_auth_via_api_keys(authorization_header)\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/\", line 225, in validate_auth_via_api_keys\n validate_api_key_secret(api_key, api_secret, authorization_source)\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/\", line 244, in validate_api_key_secret\n doc_secret = frappe.utils.password.get_decrypted_password(doctype, doc, fieldname=‘api_secret’)\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/utils/\", line 62, in get_decrypted_password\n frappe.throw(_(\“Password not found\”), frappe.AuthenticationError)\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/\", line 438, in throw\n msgprint(msg, raise_exception=exc, title=title, indicator=‘red’, is_minimizable=is_minimizable, wide=wide, as_list=as_list)\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/\", line 417, in msgprint\n _raise_exception()\n File \"/home/frappe/frappe-bench/apps/frappe/frappe/\", line 371, in _raise_exception\n raise raise_exception(msg)\nfrappe.exceptions.AuthenticationError: Password not found\n"]",
“_server_messages”: “[”{\“message\”: \“Password not found\”, \“indicator\”: \“red\”, \“raise_exception\”: 1}"]"
at null.createError (/opt/ee/node_modules/axios/lib/core/createError.js:16:15)
at null.settle (/opt/ee/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/opt/ee/node_modules/axios/lib/adapters/http.js:236:11)
at IncomingMessage.emit (events.js:412:35)
at null.endReadableNT (internal/streams/readable.js:1317:12)
at process.processTicksAndRejections (internal/process/task_queues.js:82:21)

@rodenp just to confirm, have you configured an API key + API secret in ERPNext, and are you entering those as a part of your connected account details?

Hi there,
I would really appreciate some help in resolving the ERPNEXT issue.
Is there anything i can do to help debug the issue?
I can successfully connect and the API key and secret are displayed correctly.
However the ${auths.erpnext.base_url}/api/method/frappe.auth.get_logged_user call fails as illustrated above.

Hi there @rodenp I’m wondering if you are already following this documentation because it says you need to pass a header like this in your request

headers: {
        'Authorization': 'token api_key:api_secret'

I’ve just tried the same request like this and it worked like a charm using Token Based Authentication!

async (events, steps, auth) => {
 return require("@pipedream/platform").axios(this, {
  url: `${auths.erpnext.base_url}/api/method/frappe.auth.get_logged_user`,
  headers: {
    Authorization: `token ${auths.erpnext.api_key}:${auths.erpnext.api_secret}`

I just discovered a solution that fixes the problem.
The documentation in ERPNEXT is not always the easiest to follow.

In ERPNEXT there are 2 places to create OAUTH/API details.
The one that i used is not linked to a user and authenticates as we have seen.
However it lacks privileges to perform API functions.
The second version that i just discovered is where you generate API keys for a user.
When i use this method then it works properly.

I’m so sorry for wasting your time @dylburger.
Thanks for everyone in this community for your help.

Please close this ticket.


Great, I’m glad that worked for you. We’ll update our docs to make this more clear!

Thanks @dylburger. Keep up the great work here at pipedream.