Skip to content

Commit d75c27d

Browse files
authored
Merge pull request #35 from ansuha/master
Facebook OAuth based login
2 parents 867c661 + f94abec commit d75c27d

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ Django poll app is a full featured polling app. You have to register in this app
3131

3232
<h2> Configuring OAuth login </h2>
3333
<details>
34-
<summary>Obtaining OAuth Client ID for Google</summary>
34+
<summary>Obtaining OAuth Client ID for Google</summary>
35+
3536

3637
1. **Go to the Google Cloud Console:**
3738
- Navigate to [Google Cloud Console](https://console.cloud.google.com/).
@@ -72,7 +73,29 @@ Django poll app is a full featured polling app. You have to register in this app
7273
For detailed instructions, refer to Google's documentation on [OAuth 2.0](https://developers.google.com/identity/protocols/oauth2).
7374
</details>
7475
76+
<details>
77+
<summary>Obtaining OAuth Client ID for Facebook</summary>
78+
79+
1. **Create a Facebook App:**
80+
- Go to the [Facebook Developers](https://developers.facebook.com/) website and log in.
81+
- Click on "My Apps" and then "Create App".
82+
- Enter the required information for your app (display name, contact email, etc.) and create the app.
83+
84+
2. **Configure Basic Settings:**
85+
- In your app dashboard, go to Settings > Basic.
86+
- Add a platform (select Website) and enter your site URL(http://127.0.0.1:8000/complete/facebook/).
87+
- Save your changes.
88+
89+
3. **Get App ID and App Secret:**
90+
91+
- Update the following settings to your settings file, replacing `'your-facebook-client-id'` and `'your-facebook-client-secret'` with your actual LinkedIn app credentials:
92+
```python
93+
SOCIAL_AUTH_FACEBOOK_OAUTH2_KEY = 'your-client-id'
94+
SOCIAL_AUTH_FACEBOOK_OAUTH2_SECRET = 'your-client-secret'
95+
```
96+
7597
98+
</details>
7699
<details>
77100
<summary>Obtaining OAuth Client ID for LinkedIn</summary>
78101

accounts/templates/accounts/login.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
<a href="{% url 'social:begin' 'linkedin-oauth2' %}" class="social-login-link" data-tooltip="Login with LinkedIn">
1313
Login with Linked<i class="fab fa-linkedin-in social-login-icon"></i>
1414
</a>
15+
<a href="{% url 'social:begin' 'facebook' %}" class="social-login-link" data-tooltip="Login with Facebook">
16+
Login with <i class="fab fa-facebook-f social-login-icon"></i>acebook
17+
</a>
18+
1519
</div>
1620
<h2 class="text-center mb-4 text-primary">Login</h2>
1721
{% if messages %}

pollme/settings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
AUTHENTICATION_BACKENDS = (
4646
'social_core.backends.google.GoogleOAuth2',
4747
'social_core.backends.linkedin.LinkedinOAuth2',
48+
'social_core.backends.facebook.FacebookOAuth2',
4849
'django.contrib.auth.backends.ModelBackend',
4950
)
5051

@@ -137,6 +138,8 @@
137138
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET ='your-client-secret'
138139
SOCIAL_AUTH_LINKEDIN_OAUTH2_KEY = 'your-client-id'
139140
SOCIAL_AUTH_LINKEDIN_OAUTH2_SECRET = 'your-client-secret'
141+
SOCIAL_AUTH_FACEBOOK_OAUTH2_KEY = 'your-client-id'
142+
SOCIAL_AUTH_FACEBOOK_OAUTH2_SECRET = 'your-client-secret'
140143

141144
SOCIAL_AUTH_URL_NAMESPACE = 'social'
142145
SOCIAL_AUTH_LOGIN_REDIRECT_URL = '/polls/list/user/'

0 commit comments

Comments
 (0)