Django sign up with facebook return an error - django-facebook

*as 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 sub-domains of your app to the App Domains field in your app settings.**
im using http://127.0.0.1:8000
so here is how i have set my facebook
domain App domains is 127.0.0.1
Then the url to the sign up page on django is
http://127.0.0.1:8000/user

first you need to install django ssl server then dont access with 127.0.0.1 but use localhost even though it will redirect you to 127.0.0.1 just use localhost:8000
Then on login to admin and on sites rename the domain name to localhost:8000
go to facebook development and add the following
domain name = localhost
go to add platform on bottom of the page and add website then fill this way
http://localhost:8000
HOW TO INSTALL DJANGO SSLSERVER
https://github.com/teddziuba/django-sslserver
HOPE IT WORKS😖😖

Related

"Facebook OAuth" The domain of this my domain isn't included in the app's domain how to add it?

when i try to set up login with facebook i keep getting this error
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 sub-domains of your app to the App Domains field in your app settings.
ps:i try a lot of solution on stackoverflow and other website

Laravel socialite Google login cannot create credentials for localhost server

I'm developing a laravel project with socialite. It is now in my localhost sever. During development, I want to test login/register locally. Hence, my domain is localhost.
I've created a project in google console but can't create credentials for my localhost domain.
https://console.developers.google.com/apis/credentials
When I try to add localhost to Authorized domains Google says Invalid domain: must be a top private domain. Here is a screenshot:
Is is possible to create credentials for localhost?

Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https://

I am implementing Passport Facebook Authentication by linking the Facebook Authentication API route to a button using href like:
Facebook Login
When I click on the button, it redirects to the Facebook Authentication page. But on the page, an error message is displayed saying something like "Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https://"
How can I fix this issue?
Amazingly I just started trying to do the same thing like an hour ago and have been having the same issue. If you go into the FB developer portal and go to Settings under Facebook Login there's an option to Enforce HTTPS.
Further Investigation Showed:
"Enforce HTTPS. This setting requires HTTPS for OAuth Redirects and pages getting access tokens with the JavaScript SDK. All new apps created as of March 2018 have this setting on by default and you should plan to migrate any existing apps to use only HTTPS URLs by March 2019. Most major cloud application hosts provide free and automatic configuration of TLS certificates for your applications. If you self-host your app or your hosting service doesn't offer HTTPS by default, you can obtain a free certificate for your domain(s) from Let's Encrypt."
Reference: Login Security
Since you're using passport, also check your auth.js settings, or where ever you keep these settings. Even if your website has a certificate, the following code will still fail:
'facebookAuth' : {
'clientID' : '.............', // App ID
'clientSecret' : '............................', // App Secret
'callbackURL' : 'localhost:9999/auth/facebook/callback',
'profileURL' : 'https://graph.facebook.com/v2.5/me?fields=first_name,last_name,email',
'profileFields' : ['id', 'email', 'name']
},
The problem lies with the callbackUrl.
'callbackURL' : '/auth/facebook/callback'
'callbackURL' : 'http://localhost:9999/auth/facebook/callback'
The statements above will both fail. The callbackUrl needs to start with https. The first one will try to load http://localhost and append the callbackUrl. The second one obiviously loads the full url with http, and both fail to connect with FB. So try one of the following. If your site has a certificate, provide the full url. If you're testing this on a localhost, create your own certificate and access it by https like:
'callbackURL' : 'https://example.com/auth/facebook/callback'
'callbackURL' : 'https://localhost:9999/auth/facebook/callback'
Since Facebook have been requiring usage of HTTPS for our redirect URIs we can use ngrok at localhost for start up a local secure HTTP tunnel. It is a clean and fast suggested alternative for now.
Get official ngrok package
Unzip to your preferred directory
unzip /opt/ngrok.zip;
Make your first HTTP tunnel: /opt/ngrok http 3000
See more great use cases in ngrok docs.
There are 2 ways you can solve that:
First:
You can go to your google Passport strategy and add proxy: true
passport.use(
new FacebookStrategy(
{
clientID: facebookID,
clientSecret: facebookSecret,
callbackURL: "/auth/facebook/callback",
proxy: true
}
)
);
What happens most of the time is that, when you deploy or app through Heroku, for example, they have a Proxy that allows Heroku to direct the requests to your specific server and Passport assumes that if your request goes through a proxy it might not be safe (So... No https).
The second way you can solve that is by using a specific path for your callbackURL.
For example, instead of using:
callbackURL: "/auth/facebook/callback"
you would use:
callbackURL: https://mydomain/auth/facebook/callback
Keep in mind that if you are going to use this approach you might need to create environment variables to hold the values of your specific redirectURL for development as well as for production.
To fix, for local development, generate ssl certs on your machine. Run the commands below(tested on Mac High Sierra, you will need the openssl lib installed on your os) to create a cert.pem and a key.pem file in your working directory.
openssl req -x509 -newkey rsa:2048 -keyout keytmp.pem -out cert.pem -days 365
openssl rsa -in keytmp.pem -out key.pem
Change your node http server to use https. You will need to import the https module in place of the http module.
const https = require('https')
const path = require('path')
const fs = require('fs')
const options = {
cert: fs.readFileSync(path.resolve(__dirname, '<path_to_your_cert.pem>')),
key: fs.readFileSync(path.resolve(__dirname, '<path_to_your_key.pem>'))
}
const server = https.createServer(options, <your_handler_or_app_eg_express>)
server.listen(<your_prefered_port_number>)
Go to the app on your facebook developer console and set the Valid OAuth Redirect URIs to the https version of your localhost domain. Do same for the app domain and site url.
In my case, I modified my package.json file.
"start": "node scripts/start.js" =>
"start": "set HTTPS=true&&node scripts/start.js"
I hope help you.
This for php sdk reference
Now https is required for the web-application to login via Facebook.
Following procedure is required get valid authentication from Facebook.
Basic Seetings
set App Domains as your root domain (www.example.com)
Privacy Policy URL (https://www.example.com/privacy-demo/)
Terms of Service URL (https://www.example.com/terms-demo/)
Set Category
Site URL (https://www.example.com/facebook-login/) facebook-login this folder contain my all facebook login files
Advanced
Server IP Whitelist (your host ip address 124.25.48.36)
Products below Facebook login settings
Valid OAuth Redirect URIs (https://www.example.com/facebook-login/fb-callback.php)
Quick start
Select website put site url (https://www.example.com/facebook-login/)
Save all changes and live your app (ie: on your app) Now your app status will live.
You can refer this code https://github.com/facebook/php-graph-sdk
use a vpn worked for me cyber ghost is free try it
In your passport setting change your redirect url to some https://someUrl
'https' is important

Facebook login Error: Cant load URL

I have this facebook app and I have setup my client id and secret on the code. When I try to access the api I get this error. I have tried everything. The app domain is localhost and the website url is the path that the app is running. Anyone know how to solve the issue?
This is the request:
https://www.facebook.com/v2.8/dialog/oauth?client_id=266389393769834&state=xxxxx&response_type=code&sdk=php-sdk-5.0.0&redirect_uri=http%3A%2F%2F%5B%3A%3A1%5D%2Fdemo%2F%2Fuser_authentication&scope=email
In order to test a localhost FB login setup, you cannot use their "Production" setup, as this points to an existing website, or IP
localhost, 127.0.0.1 or any alias (for example: my.domain or de.mo) you set on your localhost server will not work when the FB settings is pointing at production environment.
You need to set up a test environment using FB "Create New App"

Custom Domain pointing to heroku app changes URL in browser?

I have an website hosted on heroku. App url is like example.herokuapp.com
I bought domain with name www.example.com and on visiting this URL I pointed to example.herokuapp.com. This works fine however URL in browser changes to heroku app rather it should stay custom domain www.example.com
What configurations are required?
That suggests you're using domain forwarding at your DNS provider and not adding a CNAME entry to your domain pointing at example.herokuapp.com for the www host

Resources