You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+91Lines changed: 91 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,8 @@ The settings of this app are:
96
96
- DRFSO2_PROPRIETARY_BACKEND_NAME sets the name of your Oauth2 social backend (e.g Facebook), defaults to "Django"
97
97
- DRFSO2_URL_NAMESPACE sets the namespace for reversing urls.
98
98
99
+
Setting up Application
100
+
**********************
99
101
100
102
Now go to django admin and add a new Application.
101
103
- client_id and client_secret shouldn't be changed
@@ -228,6 +230,10 @@ To use Facebook as the authorization backend of your django-rest-framework api,
228
230
'fields': 'id, name, email'
229
231
}
230
232
233
+
Remember to add new Application in your Django admin (see section "Setting up Application").
234
+
235
+
Testing
236
+
*******
231
237
232
238
- You can test these settings by running the following command :
233
239
@@ -240,3 +246,88 @@ You can find the id and secret of your app at https://developers.facebook.com/ap
240
246
For testing purposes you can use the access token `<user_access_token>` from https://developers.facebook.com/tools/accesstoken/.
241
247
242
248
For more information on how to configure python-social-auth with Facebook visit http://python-social-auth.readthedocs.io/en/latest/backends/facebook.html.
249
+
250
+
251
+
Google Example
252
+
--------------------
253
+
254
+
To use Google OAuth2 as the authorization backend of your django-rest-framework api, your settings.py file should look like this:
Remember to add new Application in your Django admin (see section "Setting up Application").
318
+
319
+
Testing
320
+
*******
321
+
322
+
You can test these settings by running the following command :
323
+
324
+
curl -X POST -d "grant_type=convert_token&client_id=<django-oauth-generated-client_id>&client_secret=<django-oauth-generated-client_secret>&backend=google-oauth2&token=<google_token>" http://localhost:8000/auth/convert-token
325
+
326
+
This request returns the "access_token" that you should use on all HTTP requests with DRF. What is happening here is that we are converting a third-party access token (<user_access_token>) in an access token to use with your api and its clients ("access_token"). You should use this token on each and further communications between your system/application and your api to authenticate each request and avoid authenticating with Google every time.
327
+
328
+
You can find the id and secret of your app at https://console.developers.google.com/apis/credentials
329
+
and more information on how to create one on https://developers.google.com/identity/protocols/OAuth2.
330
+
331
+
For testing purposes you can use the access token `<user_access_token>` from https://developers.google.com/oauthplayground/.
332
+
333
+
For more information on how to configure python-social-auth with Google visit https://python-social-auth.readthedocs.io/en/latest/backends/google.html#google-oauth2.
0 commit comments