• Members 10 posts
    July 25, 2021, 5:45 a.m.

    Hey Rafal,

    I am using the Misago as my backend to support forum. I recently trying to using the github login. I can locally setup the Github oauth with no error(with github callback to localhost:8000) But when I test it with remote server in AWS. It complains with NoneType object has no attribute provider error.

    here is the detailed log:

    backend_1  | Internal Server Error: /complete/github/
    backend_1  | Traceback (most recent call last):
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    backend_1  |     response = get_response(request)
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    backend_1  |     response = self.process_exception_by_middleware(e, request)
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    backend_1  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    backend_1  |     response = view_func(request, *args, **kwargs)
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    backend_1  |     return view_func(*args, **kwargs)
    backend_1  |   File "/srv/misago/misago/socialauth/views.py", line 35, in social_auth_view_wrapper
    backend_1  |     return f(request, backend, *args, **kwargs)
    backend_1  |   File "/srv/misago/misago/socialauth/views.py", line 57, in complete
    backend_1  |     **kwargs
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/social_core/actions.py", line 73, in do_complete
    backend_1  |     social_user.provider)
    backend_1  | AttributeError: 'NoneType' object has no attribute 'provider'
    backend_1  | Internal Server Error: /complete/github/
    backend_1  | Traceback (most recent call last):
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    backend_1  |     response = get_response(request)
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
    backend_1  |     response = self.process_exception_by_middleware(e, request)
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
    backend_1  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    backend_1  |     response = view_func(request, *args, **kwargs)
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    backend_1  |     return view_func(*args, **kwargs)
    backend_1  |   File "/srv/misago/misago/socialauth/views.py", line 35, in social_auth_view_wrapper
    backend_1  |     return f(request, backend, *args, **kwargs)
    backend_1  |   File "/srv/misago/misago/socialauth/views.py", line 57, in complete
    backend_1  |     **kwargs
    backend_1  |   File "/usr/local/lib/python3.7/site-packages/social_core/actions.py", line 73, in do_complete
    backend_1  |     social_user.provider)
    backend_1  | AttributeError: 'NoneType' object has no attribute 'provider'
    backend_1  | [25/Jul/2021 03:39:21] "POST /complete/github/ HTTP/1.1" 500 21345
    

    I did some research with github.com/python-social-auth/social-app-django/issues/284 and github.com/omab/python-social-auth/issues/989 but doesn't work.

    Do you have this issue before?

    Thanks in advance.

  • July 26, 2021, 2:21 a.m.

    I'm sorry. I'm not familiar with the issue you are having here. You've said auth is working on localhost but not on AWS. Maybe config is not completely accurate on Github side?

  • Members 10 posts
    July 26, 2021, 4:55 a.m.

    hey Rafal, thanks for your reply.

    I finally found the issue, basically the issue was in table social_auth_usersocialauth. There is no social auth record linked to the user created by social auth in misago_users_user table(User created in misago_users_user table but not in social_auth_usersocialauth). Which causing

                social_user = user.social_user
                login(backend, user, social_user)
                # store last login backend name in session
                backend.strategy.session_set('social_auth_last_login_backend',
                                             social_user.provider)
    

    The social_user to be none in the do_complete function.

    So I suspect the insert row operation in social_auth_usersocialauth failed.

    Then I compared my local table with the gamma version on AWS. I saw two extra row local table does not have which are created and modified. Both are value required column.

    I change those two column to be optional column. And the social auth works now :)

    I am not sure why I got two extra columns for my AWS misago setup. I will digin later. Now just want to cheer on my bug fix hahaha

  • July 27, 2021, 1:46 a.m.

    am not sure why I got two extra columns for my AWS misago setup.

    Sounds like your AWS installation uses different version of social auth?

  • Members 10 posts
    July 27, 2021, 3:33 a.m.

    I don't think so since the requirements.txt are the same. Still digging