Django-allauth Facebook error - django

I am going to implement login with facebook and google using django-allauth app,but i am getting one error i.e
You are not logged in: You are not logged in. Please log in and try again.
My Facebook App Settings
What should i do now??

Change your redirect URI to
http://localhost:8000/accounts/facebook/login/callback/
and also make sure to have SITE_ID = 1 in settings.

The following solved my problem:
Valid Oauth redirect URI ---> set to http://localhost:8000/

Related

Django allauth Access blocked: This app’s request is invalid

I'm using django allauth. Everything working fine, except when trying to signup using Google. I got this error: Access blocked: This app’s request is invalid.
Is there any solution to this?
Here is my Google Developer Console:
I've also tried to change http to https and it's also not working
You url is not matching with google url please correct your url in Clound console.
So in my case, what I have to do is change the Authorized redirect URLs from:
http://localhost:8000/accounts/google/login/callback/
http://127.0.0.1:8000/accounts/google/login/callback/
to
http://localhost:8000/google/login/callback/
http://127.0.0.1:8000/google/login/callback/
just remove the "accounts/" and it works fine.

Bypass Django admin login by using another authentication method

Is there a way, when hitting Django admin site, it redirects to a 3rd party authentication page. User logs in there, then gets redirected back to Admin site without having to log in again?
Basically I want to replace Django admin login by another authentication, so I can insert a link to my web app and admins can access admin page right away.
EDIT:
did a bit more research and will refine my problem.
Say I want to login from http://localhost:8000/admin/login/, I assume I need to redirect the user/admin to the 3rd party login page, then once the auth is successful, I should redirect him back to the next page after login. Where/what should I modify?
EDIT2:
I'm following this example
https://auth0.com/docs/sso/current/single-page-apps
Could get the server to run on 5000 but the auth still fails and returns 400
How do I get from my React app in localhost:3000 to my django admin page in localhost:8000 without needing to log in again?
Yes, its possible, you can use authenticate functions to authenticate your request, so when your come back from your 3rd party authentication page you get your response being success or failed and run authenticate function and now your user will be logged... this is kinda a dirty way to do that...
You can also write your own Authentication method and setup at your settings
https://docs.djangoproject.com/en/2.0/topics/auth/customizing/

Facebook login is not working on website

can someone please help me. I am getting the following error when trying to login with Facebook:
URL Blocked: This redirect failed because the redirect URI is not
whitelisted in the app’s Client OAuth Settings. Make sure Client and
Web OAuth Login are on and add all your app domains as Valid OAuth
Redirect URIs.
My redirect URI is: http://127.0.0.1:8000/auth/complete/facebook
you can change your URI from this:
http://127.0.0.1:8000/auth/complete/facebook
to this:
http://127.0.0.1:8000/en/auth/complete/facebook
you can add for each tranlation you may add. (en, fr, etc)
Hope it helps.

Facebook Social Auth Login: Can't Load URL: The domain of this URL isn't included in the app's domains

I am developing a web application using Django and python-social-auth. I want users to login with Facebook.
I have this in my python settings:
SOCIAL_AUTH_FACEBOOK_KEY = '...'
SOCIAL_AUTH_FACEBOOK_SECRET = '...'
SOCIAL_AUTH_FACEBOOK_SCOPE = ['email']
When my users enter the facebook page where they should provide credentials they see an error like this:
Can't Load URL: The domain of this URL isn't included in the app's domains.
To be able to load this URL, add all domains and subdomains of your
app to the App Domains field in your app settings.
In Facebook for Developers dashboard I have added "Facebook Login" product and added redirect url:
http://localhost:8000/complete/facebook/
In settings, Website Site URL is set to: http://localhost:8000/ and App Domains is set to localhost.
What am I doing wrong?
BTW this is the url that my users see when the facebook page opens:
https://www.facebook.com/v2.9/dialog/oauth?scope=email&state=HSfkstGUR5028DMhUzfWOSgo6fpPx29E&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fcomplete%2Ffacebook%2F%3Fredirect_state%3DHSfkstGUR5028DMhUzfWOSgo6fpPx29E&client_id=...&return_scopes=true
Disable the 'Use Strict Mode for Redirect URIs' setting in your Facebook login app.
OR
Note the redirect_uri=http%3A%2F%2Flocalhost%3A8000%2Fcomplete%2Ffacebook%2F%3Fredirect_state%3DHSfkstGUR5028DMhUzfWOSgo6fpPx29E parameter of generated url.
For some inexplicable reason Facebook requires Valid OAuth redirect URIs setting to be exactly the same as the redirect url.
So use a tool like https://meyerweb.com/eric/tools/dencoder/, decode the url and set Valid OAuth redirect URIs to the full url. I.E:
http://localhost:8000/complete/facebook/redirect_state=HSfkstGUR5028DMhUzfWOSgo6fpPA59E
Upgrading social-auth-core to at least version 1.6.0 should help to resolve this. Among other changes it includes this one:
Default REDIRECT_STATE to False in FacebookOAuth2 backend.
This was changed as a result of issue 141, and it causes redirect URLs to be generated without the redirect_state argument, whose dynamic value makes whitelisting impossible.
Once you've done this, add https://<your-domain>/complete/facebook/ to your OAuth redirect whitelist in the Facebook developer portal.
Facebook doesn't like localhost in the Redirect URI field in the app setup or in the redirect_uri parameter. To workaround it just set something in the field (I use http://myapp.com:8000, then add the entry 127.0.0.1 myapp.com in your /etc/hosts and access the app through the new URL (http://myapp.com:8000).
As of the 4th April 2018, day i face the same issue, the only solution i found is:
Valid OAuth redirect URIs must be set to be exactly the same as the redirect url
More info here: https://developers.facebook.com/blog/post/2017/12/18/strict-uri-matching/

Valid OAuth redirect URIs for facebook - Django Social Auth

I am referring tutorials to implement django social-auth, I hace successfully implemented it for Twitter and Google+ . But, in case of facebook , I am not seeing "Valid OAuth redirect URIs" which has to provided for facebook. I assume that the new developer console of facebook has this new field.
By leaving the field empty, I am still able to login but I am not getting relevent details from FB. It might be because of this "redirect URI".
I followed below tutorials
Tutorial 1
Tutorial 2
I guessed that "http://localhost:8000/oauth/complete/facebook/" could be the URI looking at google+ and twitter pattern but I am still not getting email ID of user.
Can someone please confirm the redirect URI that has been used by them for Facebook in their Django App
The problem is that Django sends a redirect_state parameter which is not allowed by Facebook redirect URI policy.
Here's a simple solution:
Create a new backend for Facebook OAuth that don't pass redirect_state:
from social_core.backends.facebook import FacebookOAuth2
class CustomFacebookOauth(FacebookOAuth2):
REDIRECT_STATE = False
change social_core.backends.facebook.FacebookOAuth2 on your CustomFacebookOauth in AUTHENTICATION_BACKENDS of settings.py.
After hours of headache I finally found out that it was
https://{your_website_name}/social-auth/complete/facebook/
e.g. https://www.instagram.com/social-auth/complete/facebook/
Note that https is made mandatory by facebook.