@@ -77,13 +77,9 @@ as a reference. What we need are these steps:
7777
7878 ``` python
7979 from identity.django import Auth
80- AUTH = Auth(" your_client_id" , client_credential = ... , authority = ... , redirect_view = " xyz " )
80+ AUTH = Auth(" your_client_id" , client_credential = ... , authority = ... , redirect_uri = ... )
8181 ```
8282
83- Generally speaking, your redirect_uri shall contain a top-level path such as
84- ` http://localhost:5000/redirect ` ,
85- then your setting here shall be ` ..., redirect_view="redirect") ` .
86-
87832 . Inside the same ` mysite/settings.py ` file,
8884 add ` "identity", ` into the ` INSTALLED_APPS ` list,
8985 to enable the default templates came with the ` identity ` package.
@@ -99,11 +95,10 @@ as a reference. What we need are these steps:
9995
10096 ``` python
10197 ...
102- from django.urls import path, include
10398 from django.conf import settings
10499
105100 urlpatterns = [
106- path( " " , include( settings.AUTH .urlpatterns)) ,
101+ settings.AUTH .urlpattern ,
107102 ...
108103 ]
109104 ```
@@ -119,7 +114,7 @@ as a reference. What we need are these steps:
119114
120115 @settings.AUTH.login_required
121116 def index (request ):
122- return HttpResponse(" Hello, if you can read this, you're signed in ." )
117+ return HttpResponse(" Hello, only signed-in user can read this." )
123118 ```
124119
125120 That is it. Now visit ` http://localhost:5000 ` again, you will see the sign-in experience.
@@ -137,6 +132,7 @@ import requests
137132
138133...
139134
135+ # here we demonstrate how to handle the error explicitly.
140136def call_downstream_api (request ):
141137 token = settings.AUTH .get_token_for_user([" your_scope1" , " your_scope2" ])
142138 if " error" in token:
@@ -152,8 +148,6 @@ def call_downstream_api(request):
152148 })
153149```
154150
155- The ` settings.AUTH.get_token_for_user(...) ` will also implicitly enforce sign-in.
156-
157151You can refer to our
158152[ full sample here] ( https://github.com/Azure-Samples/ms-identity-python-webapp-django )
159153to pick up other minor details, such as how to modify ` urls.py ` accordingly,
0 commit comments