GithubHelp home page GithubHelp logo

Comments (10)

alexisluque avatar alexisluque commented on July 19, 2024

Hi @shazadan, to integrate Auth0 with django-allauth follow the steps:
In the root directory of the project created by cookie cutter, go to config/settings/base.yml file:

  • In THIRD_PARTY_APPS add the Auth0 provider
THIRD_PARTY_APPS = [
    # ...
    'allauth.socialaccount.providers.auth0',
]
  • Add you Auth0's domain:
SOCIALACCOUNT_PROVIDERS = {
    'auth0': {
        'AUTH0_URL': 'https://youraccount.auth0.com',
    }
}

For the next step you need the Django admin user created.
Log in into django admin site (http://yoururl/admin). Once logged in, you need to create a social app for your Auth0 app, Go to http://yoururl/admin/socialaccount/socialapp/add/, and fill the form with the following information:

  • On provider combobox select Auth0.
  • Set the name you want for your app.
  • Set up Client Id and Secret Key with Client ID and Client Secret respectively from your Auth0's dashboard.
  • In sites, add the site in Available sites into Choosen sites.

from auth0-django-web-app.

shazadan avatar shazadan commented on July 19, 2024

@alexisluque I followed the steps above. I created an account in Auth0. Tried logging in with it and got the error

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 66, in call
return self.application(environ, start_response)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 146, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 81, in get_response
response = self._middleware_chain(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 95, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 95, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 95, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 95, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 95, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 95, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 95, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/utils/deprecation.py", line 95, in call
response = self.get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 37, in inner
response = response_for_exception(request, exc)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 87, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 122, in handle_uncaught_exception
return debug.technical_500_response(request, *exc_info)
File "/usr/local/lib/python3.6/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
six.reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.6/contextlib.py", line 52, in inner
return func(*args, **kwds)
File "/usr/local/lib/python3.6/site-packages/allauth/socialaccount/providers/oauth2/views.py", line 73, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/allauth/socialaccount/providers/oauth2/views.py", line 134, in dispatch
response=access_token)
File "/usr/local/lib/python3.6/site-packages/allauth/socialaccount/providers/auth0/views.py", line 29, in complete_login
'user_id': extra_data['user_id'],
KeyError: 'user_id'

from auth0-django-web-app.

shazadan avatar shazadan commented on July 19, 2024

@alexisluque have you had a chance to review the above error?

from auth0-django-web-app.

aaguiarz avatar aaguiarz commented on July 19, 2024

Hi @shazadan, can you provide us a sample we can run and test?

Thanks

from auth0-django-web-app.

shazadan avatar shazadan commented on July 19, 2024

@aaguiarz

I have outlined the steps to replicate the problem:

Step 1. Download and install django cookie cutter by following instructions at https://github.com/pydanny/cookiecutter-django

Step 2. Follow the 'Getting Up and Running Locally With Docker'

Step 3. Follow steps outlined by @alexisluque to integrate auth0 with django using allauth

Step 4. Setup a user account in Auth0

Step 5. Try logging in with that user in django and you will get the above error.

Best,

Shazada

from auth0-django-web-app.

alexisluque avatar alexisluque commented on July 19, 2024

@shazadan try the following:
Go to application settings in your dahsborad, click on Show Advanced Settings, in OAut tab disable the option OIDC Conformant.

from auth0-django-web-app.

shazadan avatar shazadan commented on July 19, 2024

@alexisluque I turned if off and am still getting the same error.

screen shot 2018-06-19 at 9 00 01 pm

from auth0-django-web-app.

aaguiarz avatar aaguiarz commented on July 19, 2024

@shazadan
when OIDC conformant = true, Auth0 returns the following profile https://auth0.com/docs/user-profile/normalized/oidc

when OIDC conformant = false, Auth0 returns the following profile https://auth0.com/docs/user-profile/normalized/auth0#sample-user-profiles

allauth is using this code to read the profile:

https://github.com/pennersr/django-allauth/blob/master/allauth/socialaccount/providers/auth0/provider.py#L26

We are going to submit a PR to allauth so it works with both profile structures, meanwhile, the instructions @alexisluque gave have been working for both of us. Can you paste the error you are getting now?

from auth0-django-web-app.

shazadan avatar shazadan commented on July 19, 2024

@aaguiarz Sorry for delayed response but I spent the weekend trying to debug what might be causing the error. Just to make sure I was following the above instructions I recreated the app twice but I keep getting the same KeyError. Would it be possible for you to jump on a screenshare with me this week and see what I am doing wrong.

from auth0-django-web-app.

jimmyjames avatar jimmyjames commented on July 19, 2024

Closing this issue as it is quite old - if you are still experiencing this issue please reopen or create a new issue, including any updated information if applicable.

from auth0-django-web-app.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.