PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 16, 2022

[FIXED] How to test Facebook login with localhost

 July 16, 2022     django, django-allauth, facebook, facebook-javascript-sdk, facebook-login     No comments   

Issue

I'm using Django, and want to make Facebook login with django-allauth.

I made Facebook login with few time, and tested it with localhost.

But I found out that FB login require https after 2018 march, so when I login fb in local runserver, it gives error 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://.

Is there any way to test fb login in localhost?


Solution

You can just use a real subdomain like dev.yourdomain.com and point its DNS to 127.0.0.1 (or can use lvh.me domain since it also point to 127.0.0.1 - but if you trust them all the time)

Then you need a layer to handle HTTPS in local for https://dev.yourdomain.com. I recommend https://caddyserver.com/

With a very simple config like this then Caddy can use its self-signed SSL cert (checkout Caddy docs to get the detail)

dev.yourdomain.com:443 {
    tls self_signed
    proxy / localhost:8080
}

Then you can open https://dev.yourdomain.com in some browsers like Firefox, Safari, Brave, etc. (I think Chrome blocked self-signed SSL site by default)

UPDATE I create a note here with more detail

https://gist.github.com/ralavay/5d74d35859f87d22c74984488f20186c



Answered By - neo0
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing