ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

Frappe OAuth2 Import Error

bug

#1

Frappe OpenIDConnectAuthCode import error when installed with python3.6 environment.

Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 66, in application response = frappe.api.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 39, in handle validate_oauth()
File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 134, in validate_oauth from frappe.oauth import get_url_delimiter
File "/home/frappe/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’

Error pops up even after I tried
pip install --upgrade oauthlib==2.1.0

Error pops up when trying to use pdf function of a print, or on data export ( basically anything that uses any frappe api )
I have not been able to recreate the bug in python2.7 environment.

I am on develop branch with versions
erpnext 11.0.3-beta.34
frappe 11.0.3-beta.48

The error in question is a simple import error, coming from
/frappe-bench/apps/frappe/frappe/api.py
and in it, the function calls
validate_oauth()
validate_auth_via_api_keys()

And the file it is supposed to come from is
/frappe-bench/env/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py

Github oauthlib authorization_code.py file link

The error is annoying and can be suppressed by simply commenting out the function calls in
/frappe-bench/apps/frappe/frappe/api.py
#validate_oauth()
#validate_auth_via_api_keys()

But then oauth2 no longer works.

Can anyone replicate this issue ? As I’ve mentioned earlier it pops up in python3.6 env.

Any suggestions are appreciated.

Also, to anyone who will say this should be in the other site, It already is.
I posted it there, post link and after waiting for 24 hours for a reply, and not getting a single view, I am posting it here.

If you need any more data, want me to run some command, whatever, please ask.
though I wont run sudo rm -rf / or sudo chmod -R 777 .* or stuff like that, you know, because my system is already fast enough, thank you.
Also, the two link limit for new users - not a fan.


#2


#3

Any updates on this ?

I had an automated message telling me my account has been put on hold as a precautionary measure and that it will be on hold until a staff member reviews it, well it’s been 20 days since and no updates.
Why was it put on hold?
Is it still ?
Is there a way to contact someone regarding this, because i did not see any way to do so.
I know this is not the right place to be posting this, and please excuse my negligence in still doing so, but where else do I do it?


#4

It’s a python 3.6 error, however if you decide to migrate-env python2.7 to fix it,
You get pickling issues.
Python 2.7 supports pickling protocols 0,1,2 and python3 by default uses protocol 3.
You can try fixing it by redis-cli FLUSHALL but if it doesn’t do the trick,
you can delete your dump.rdb if you’re brave enough.

Make this post visible and close it so others can read this thread and maybe get some insights.