3.4 KiB
Social Auth notes
basic python_social_auth
How to Add Social Login to Django
How to Add Social Login to Django
pre test notes
- disable 'test_social.middleware.ForwardHQMiddleware'
- reset LOGIN_REDIRECT_URL = '/tsoc' or to wherever you want it to land
- set SOCIAL_AUTH_URL_NAMESPACE = 'social'
- DON'T use localhost if you plan on using twitter, twitter doesn't like it
error in login
change:
path('login/', views.login, name='login')
path('login/', views.LoginView.as_view(template_name="registration/login.django"), name='login')
when making callback urls
-
you can use localhost
-
you can also specify a port on localhost, e.g. http://localhost:8026
-
you can also use minyanfinder.stg or any .stg
-
make sure to specify the "u" letter in oauth
-
make sure to add the final forward slash "/" at the end of the callback url
minyanfinder.stg/oauth/complete/twitter/
global variables
global variables should be in settings.py
local info like the specific client id/secret key, etc, should be in the local setting sfiles
test_social should only be activated in the local setting files
twitter notes
- you want to either use http or https, be specific
- twitter does not use localhost and forwardhq is buggy
- twitter DOES register 127.0.0.1:8026 as a callback
facebook notes
- can use localhost
- minaynfinder.stg is not working, need a certificate of some kind
- forwardhq also not working
using a domain
create registered users
Go to Roles->Test Users
create the ssl
-
set a registered domain name to point at the ip address (ie ronnyabraham.com)
-
create a [https://www.digitalocean.com/community/tutorials/openssl-essentials-working-with-ssl-certificates-private-keys-and-csrs#generating-ssl-certificates](crt certificate)
-
Settings->Basic-> App Domainsaddronnyabraham.com -
Settings->Basic->Website/Site URLaddhttps://ronnyabraham.com -
in Products->FacebookLogin->Settings add the following to "VAlid OAuth Redirect URIs"
- use letsencrypt to create ssl keys
setting up facebook
-
if used for testing make sure you set the app FOR TESTING you have to do this in the create app stage
-
go to settings->basic get the app-id and app-secret
-
go to Settings-Basic-App Domains and add your FQDN (ie. mycrustyass.com)
-
go to Settings-Basic-Website (it's near the bottom, add website if it isn't there), add the site URL with it's prefix ie http or https.
Step 5 is VERY IMPORTANT b/c facebook doesn't recognize http prefix. You must have SSL set up. But this is NOT the caes with localhost!
- in Settings-Products add Facebook Login then set Web OAuth Login to true
- Settings-Products-Facebook Login add Valid OAuth redirect calls.
Important! You must find out what the specific redirect call looks like. Once again, facebook doesn't require this for localhost, but for a named host it does
e.g. https://mycrustyass.com/oauth/complete/facebook/
- test this URL in the Settings-Products-FAcebook Login-Redirect URL Validator