Skip to content

Commit bbe4192

Browse files
committed
Rename "downstream api" to simply "call api"
1 parent 7b31de6 commit bbe4192

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ to sign in users and make authenticated calls to the Microsoft Graph API.
1919

2020
### Installation
2121

22-
1. This sample already implements sign-in and calling downstream API.
22+
1. This sample already implements sign-in and calling a web API.
2323
You can clone
2424
[its repo](https://github.com/Azure-Samples/ms-identity-python-webapp-django)
2525
or download its zip package, and then start using it or build on top of it.
@@ -138,7 +138,7 @@ as a reference. What we need are these steps:
138138
### Chapter 2: Get an Access Token and call Microsoft Graph
139139

140140
This chapter begins where chapter 1 left off.
141-
We will add the following new view which will call a downstream API.
141+
We will add the following new view which will call a web API.
142142

143143
```python
144144
import json
@@ -148,11 +148,11 @@ import requests
148148
...
149149

150150
# here we demonstrate how to handle the error explicitly.
151-
def call_downstream_api(request):
151+
def call_web_api(request):
152152
token = settings.AUTH.get_token_for_user(["your_scope1", "your_scope2"])
153153
if "error" in token:
154154
return redirect(settings.AUTH.login)
155-
api_result = requests.get( # Use access token to call downstream api
155+
api_result = requests.get( # Use access token to call a web api
156156
"https://example.com/your/api",
157157
headers={'Authorization': 'Bearer ' + token['access_token']},
158158
timeout=30,

mysite/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
urlpatterns = [
2525
settings.AUTH.urlpattern,
2626
path('', views.index),
27-
path("call_downstream_api", views.call_downstream_api),
27+
path("call_api", views.call_api),
2828
path('admin/', admin.site.urls),
2929
]

mysite/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ def index(request, *, context):
1515
user=context['user'],
1616
version=__version__,
1717
edit_profile_url=settings.AUTH.get_edit_profile_url(),
18-
downstream_api=os.getenv("ENDPOINT"),
18+
api_endpoint=os.getenv("ENDPOINT"),
1919
))
2020

2121
@settings.AUTH.login_required(scopes=os.getenv("SCOPE", "").split())
22-
def call_downstream_api(request, *, context):
22+
def call_api(request, *, context):
2323
api_result = requests.get( # Use access token to call a web api
2424
os.getenv("ENDPOINT"),
2525
headers={'Authorization': 'Bearer ' + context['access_token']},
2626
timeout=30,
2727
).json() if context.get('access_token') else "Did you forget to set the SCOPE environment variable?"
2828
return render(request, 'display.html', {
29-
"title": "Result of downstream API call",
29+
"title": "Result of API call",
3030
"content": json.dumps(api_result, indent=4),
3131
})
3232

templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ <h2>Welcome {{ user.name }}!</h2>
1515
<img src="https://github.com/Azure-Samples/ms-identity-python-webapp-django/raw/main/static/topology.png" alt="Topology">
1616

1717
<ul>
18-
{% if downstream_api %}
19-
<li><a href='/call_downstream_api'>Call a downstream API</a></li>
18+
{% if api_endpoint %}
19+
<li><a href='/call_api'>Call an API</a></li>
2020
{% endif %}
2121

2222
{% if edit_profile_url %}

0 commit comments

Comments
 (0)