Frappe. Cannot import name OpenIDConnectAuthCode when trying to access api

I am trying to access API by /api/resouce/MyDoctype on the new installation of frappe and getting this error:

Traceback (most recent call last):
  File "/home/siarhei/WorkProjects/kanban/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
    response = frappe.api.handle()
  File "/home/siarhei/WorkProjects/kanban/frappe-bench/apps/frappe/frappe/api.py", line 39, in handle
    validate_oauth()
  File "/home/siarhei/WorkProjects/kanban/frappe-bench/apps/frappe/frappe/api.py", line 134, in validate_oauth
    from frappe.oauth import get_url_delimiter
  File "/home/siarhei/WorkProjects/kanban/frappe-bench/apps/frappe/frappe/oauth.py", line 8, in 
    from oauthlib.oauth2.rfc6749.grant_types import AuthorizationCodeGrant, ImplicitGrant, ResourceOwnerPasswordCredentialsGrant, ClientCredentialsGrant,  RefreshTokenGrant, OpenIDConnectAuthCode
ImportError: cannot import name OpenIDConnectAuthCode

Same error when I am trying to access login api.

Any ideas?

Frappe version v12.x.x-develop () (develop)

2 Likes

im having the same issue while doing an import. I have installed erpnext manually. Does anyone has any idea ?

@trueno
@clarkej
Did you get the solution ?

I have made a curl using postmen

curl_setopt_array($curl, array(
CURLOPT_PORT => “8000”,
CURLOPT_URL => “http://0.0.0.0:8000/api/method/login”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “{"usr":"Administrator","pwd":"admin"}”,
CURLOPT_HTTPHEADER => array(
“Content-Type: application/json”,
“Postman-Token: d94ef222-cace-4582-8166-416e5db9593d”,
“cache-control: no-cache”
),
));

It Works Good for branch/develop for Erpnext.
But when I used it on Master It gives me the server error

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 67, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 37, in handle
validate_oauth()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 131, in validate_oauth
from frappe.oauth import get_url_delimiter
File “/home/frappe/frappe-bench/apps/frappe/frappe/oauth.py”, line 7, in
from oauthlib.oauth2.rfc6749.grant_types import AuthorizationCodeGrant, ImplicitGrant, ResourceOwnerPasswordCredentialsGrant, ClientCredentialsGrant, RefreshTokenGrant, OpenIDConnectAuthCode
ImportError: cannot import name OpenIDConnectAuthCode
Home
Status: 500

Any help would be much appropriated.
Thanks,

No I didnt get any solution. I am also waiting for an Angel to reply :slight_smile:

1 Like

I am facing same problem.

I resolved the issue!

Please make sure that
/frappe-bench/apps/frappe/requirements.txt File have
Following line included
oauthlib==2.1.0

After that run following command:

bench setup requirements
And
Don’t for get to run
bench clear-cache

Cheers!

3 Likes

Actually Oauthlib 3.0.0 was released recently which causes the problem.

This issue is mentioned here in issue 6749 and you can find the commit for this here in this PR 6756

1 Like

@aly
Thanks for your help mate!

Thanks its working.

1 Like

This worked very well.
I was able to import and download the template.

However, I cannot search
Is there anything you can help with the following error (whatever I type in search, it gives the following error)

Traceback (most recent call last):
  File "/opt/bench/erpnext/apps/frappe/frappe/app.py", line 55, in application
    response = frappe.handler.handle()
  File "/opt/bench/erpnext/apps/frappe/frappe/handler.py", line 20, in handle
    data = execute_cmd(cmd)
  File "/opt/bench/erpnext/apps/frappe/frappe/handler.py", line 55, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/opt/bench/erpnext/apps/frappe/frappe/__init__.py", line 1013, in call
    return fn(*args, **newargs)
  File "/opt/bench/erpnext/apps/frappe/frappe/utils/help.py", line 26, in get_help
    return HelpDatabase().search(text)
  File "/opt/bench/erpnext/apps/frappe/frappe/utils/help.py", line 81, in search
    select title, intro, path from help where match(content) against (%s) limit 10''', ('%'+words+'%', words))
  File "/opt/bench/erpnext/apps/frappe/frappe/database/database.py", line 155, in sql
    self._cursor.execute(query, values)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 517, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 732, in _read_query_result
    result.read()
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 1075, in read
    first_packet = self.connection._read_packet()
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/pymysql/connections.py", line 684, in _read_packet
    packet.check_error()
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/opt/bench/erpnext/env/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
ProgrammingError: (1146, u"Table '_1bd3e0294da19198.help' doesn't exist")

Please visit this thread

You are an angel.

This helped. It is able to search.
Many many thanks.

1 Like


I am also have same error,after Include oauthlib==2.1.0 in my requirement text ,It solved

For your login page issue there’s this reported fix I install erpnext in my server, but when i brows it give login page disorder like screen short below - #2 by clarkej