The Reddit completion backend should complete successfully, create a new user, all that jazz. I hope this doesn't come across as too much of a "help I'm confused" issue, but I've gotten other backends working without issue (Spotify, Twitter).
Actual behaviour
After going to /login/reddit (which redirects to https://ssl.reddit.com/api/v1/authorize) and authorizing the app, the redirect to /complete/reddit errors with a 403 response. I'm guessing Reddit expects the request headers to be different.
Set the callback url to http://127.0.0.1:8000/complete/reddit/ or your desired url
Django specific steps follow:
Add social_core.backends.reddit.RedditOAuth2 to your AUTHENTICATION_BACKENDS in settings.py
Set SOCIAL_AUTH_REDDIT_KEY and SOCIAL_AUTH_REDDIT_SECRET vars in settings.py
Add path('', include('social_django.urls', namespace='social')) to urls.py
Run migrations (./manage.py migrate), any other required setup
./manage.py runserver
Visit http://127.0.0.1:8000/login/reddit/, which will redirect you to Reddit's OAuth screen
Click Allow
The following traceback appears
Any logs, error output, etc?
Traceback (most recent call last):
File "/.venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/.venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/.venv/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/.venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/.venv/lib/python3.8/site-packages/social_django/utils.py", line 49, in wrapper
return func(request, backend, *args, **kwargs)
File "/.venv/lib/python3.8/site-packages/social_django/views.py", line 31, in complete
return do_complete(request.backend, _do_login, user=request.user,
File "/.venv/lib/python3.8/site-packages/social_core/actions.py", line 45, in do_complete
user = backend.complete(user=user, *args, **kwargs)
File "/.venv/lib/python3.8/site-packages/social_core/backends/base.py", line 40, in complete
return self.auth_complete(*args, **kwargs)
File "/.venv/lib/python3.8/site-packages/social_core/utils.py", line 248, in wrapper
return func(*args, **kwargs)
File "/.venv/lib/python3.8/site-packages/social_core/backends/oauth.py", line 391, in auth_complete
return self.do_auth(response['access_token'], response=response,
File "/.venv/lib/python3.8/site-packages/social_core/utils.py", line 248, in wrapper
return func(*args, **kwargs)
File "/.venv/lib/python3.8/site-packages/social_core/backends/oauth.py", line 397, in do_auth
data = self.user_data(access_token, *args, **kwargs)
File "/.venv/lib/python3.8/site-packages/social_core/backends/reddit.py", line 38, in user_data
return self.get_json(
File "/.venv/lib/python3.8/site-packages/social_core/backends/base.py", line 241, in get_json
return self.request(url, *args, **kwargs).json()
File "/.venv/lib/python3.8/site-packages/social_core/backends/base.py", line 237, in request
response.raise_for_status()
File "/.venv/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
Exception Type: HTTPError at /complete/reddit/
Exception Value: 403 Client Error: Forbidden for url: https://oauth.reddit.com/api/v1/me.json
Expected behaviour
The Reddit completion backend should complete successfully, create a new user, all that jazz. I hope this doesn't come across as too much of a "help I'm confused" issue, but I've gotten other backends working without issue (Spotify, Twitter).
Actual behaviour
After going to /login/reddit (which redirects to
https://ssl.reddit.com/api/v1/authorize
) and authorizing the app, the redirect to /complete/reddit errors with a 403 response. I'm guessing Reddit expects the request headers to be different.What are the steps to reproduce this issue?
http://127.0.0.1:8000/complete/reddit/
or your desired urlsocial_core.backends.reddit.RedditOAuth2
to yourAUTHENTICATION_BACKENDS
insettings.py
SOCIAL_AUTH_REDDIT_KEY
andSOCIAL_AUTH_REDDIT_SECRET
vars insettings.py
path('', include('social_django.urls', namespace='social'))
tourls.py
./manage.py migrate
), any other required setup./manage.py runserver
http://127.0.0.1:8000/login/reddit/
, which will redirect you to Reddit's OAuth screenAny logs, error output, etc?