Request Method: GET
Request URL: http://www.example.com/oauth/complete/facebook/?granted_scopes=public_profile&denied_scopes&code=AQBoM1W9l8X1lnsYCaspOQVi1nxYG1Vh3IDkdXOw1dcW5tG6dNfjzbrQ0APZlpIquhjdeMLsQ6Wd_vktM_7pCv2GI-Uqsvya7iVm7jdnX2nbaMPkF2f7JgznpVZLh5oRXQv2AvG0Syu-GZ4skYp2ZVDNvuWdfEu-OnpN_d0GsY-P07BwwsCIlIwL6CrR0GCjNK3_wSC4c8BTWXS9fPeKd7rQOZB863x9wEwVQDjCx-LgxL41_rGJlIbk01pFWPCze5GZvsFJe8xAvbzjO9E1Jrq6KGf2pddF4-78q3xLz-IG3Ary31DoSHS2POmb-KrPvMQvK96ouft-vUBUFcoEe83P&state=nTPuVRtqNf8wSmU9SiFRYozizutSAoAd
Django Version: 3.2.5
Python Version: 3.8.10
Installed Applications:[
'admin_interface',
'colorfield',
'carparking.apps.CarparkingConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'social_django'
]
Installed Middleware:[
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'social_django.middleware.SocialAuthExceptionMiddleware'
]
Traceback (most recent call last):
File "/home/pratik/myproject/env/lib/python3.8/site-packages/social_core/utils.py", line 248, in wrapper
return func(*args, **kwargs)
File "/home/pratik/myproject/env/lib/python3.8/site-packages/social_core/backends/facebook.py", line 97, in auth_complete
response = self.request(self.access_token_url(), params={
File "/home/pratik/myproject/env/lib/python3.8/site-packages/social_core/backends/base.py", line 238, in request
response.raise_for_status()
File "/home/pratik/myproject/env/lib/python3.8/site-packages/requests/models.py", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
During handling of the above exception (400 Client Error: Bad Request for url:
https://graph.facebook.com/v8.0/oauth/access_token?client_id=Client_ID&redirect_uri=http%3A%2F%2Fwww.example.com%2Foauth%2Fcomplete%2Ffacebook%2F&client_secret=Client_Secret&code=AQBoM1W9l8X1lnsYCaspOQVi1nxYG1Vh3IDkdXOw1dcW5tG6dNfjzbrQ0APZlpIquhjdeMLsQ6Wd_vktM_7pCv2GI-Uqsvya7iVm7jdnX2nbaMPkF2f7JgznpVZLh5oRXQv2AvG0Syu-GZ4skYp2ZVDNvuWdfEu-OnpN_d0GsY-P07BwwsCIlIwL6CrR0GCjNK3_wSC4c8BTWXS9fPeKd7rQOZB863x9wEwVQDjCx-LgxL41_rGJlIbk01pFWPCze5GZvsFJe8xAvbzjO9E1Jrq6KGf2pddF4-78q3xLz-IG3Ary31DoSHS2POmb-KrPvMQvK96ouft-vUBUFcoEe83P), another exception occurred:
File "/home/pratik/myproject/env/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/pratik/myproject/env/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/pratik/myproject/env/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/pratik/myproject/env/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/pratik/myproject/env/lib/python3.8/site-packages/social_django/utils.py", line 49, in wrapper
return func(request, backend, *args, **kwargs)
File "/home/pratik/myproject/env/lib/python3.8/site-packages/social_django/views.py", line 31, in complete
return do_complete(request.backend, _do_login, user=request.user,
File "/home/pratik/myproject/env/lib/python3.8/site-packages/social_core/actions.py", line 45, in do_complete
user = backend.complete(user=user, *args, **kwargs)
File "/home/pratik/myproject/env/lib/python3.8/site-packages/social_core/backends/base.py", line 40, in complete
return self.auth_complete(*args, **kwargs)
File "/home/pratik/myproject/env/lib/python3.8/site-packages/social_core/utils.py", line 251, in wrapper
raise AuthCanceled(args[0], response=err.response)
Exception Type: AuthCanceled at /oauth/complete/facebook/
Exception Value: Authentication process canceled
I think this error because of it requesting on http tell me how to redirect it to https and SOCIAL_AUTH_REDIRECT_IS_HTTPS = True this is not working. and my reditect url is https://www.example.com/oauth/complete/facebook/ and also added without www https://example.com/oauth/complete/facebook/
hello i got the solution infact i will not call it solution but when i made some changes in urls.py and changed in redirect url of facebook then it worked
I have done these changes-
My old path in urls.py was path('oauth/', include('social_django.urls', namespace='social')), so I changed it to path(' ', include('social_django.urls', namespace= 'social')), and my old redirect url to facebook was https://example.com/oauth/complete/facebook/ and i add this https://example.com/complete/facebook/ then it worked in production