Skip to content

Commit 42b3be4

Browse files
committed
added quickstart repo link to the cte python
1 parent e48f519 commit 42b3be4

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

articles/communication-services/quickstarts/includes/manage-teams-identity-python.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ ms.author: gistefan
1515

1616
## Set up prerequisites
1717

18-
- [Python](https://www.python.org/downloads/) 2.7 or 3.6+.
18+
- [Python](https://www.python.org/downloads/) 3.7+.
19+
20+
## Final code
21+
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-python-quickstarts/tree/main/manage-teams-identity-mobile-and-desktop).
1922

2023
## Set up
2124

@@ -32,13 +35,13 @@ ms.author: gistefan
3235
```python
3336
import os
3437
from azure.communication.identity import CommunicationIdentityClient, CommunicationUserIdentifier
38+
from msal.application import PublicClientApplication
3539

3640
try:
3741
print("Azure Communication Services - Access Tokens Quickstart")
3842
# Quickstart code goes here
3943
except Exception as ex:
40-
print("Exception:")
41-
print(ex)
44+
print(f"Exception: {ex}")
4245
```
4346

4447
### Install the package
@@ -55,18 +58,21 @@ pip install msal
5558
The first step in the token exchange flow is getting a token for your Teams user by using [Microsoft.Identity.Client](../../../active-directory/develop/reference-v2-libraries.md). In Azure portal, configure the Redirect URI of your "Mobile and Desktop application" as `http://localhost`.
5659

5760
```python
58-
from msal.application import PublicClientApplication
59-
60-
client_id = "<contoso_application_id>"
61-
tenant_id = "<contoso_tenant_id>"
61+
# This code demonstrates how to fetch your Azure AD client ID and tenant ID
62+
# from an environment variable.
63+
client_id = os.environ["AAD_CLIENT_ID"]
64+
tenant_id = os.environ["AAD_TENANT_ID"]
6265
authority = "https://login.microsoftonline.com/%s" % tenant_id
6366

67+
# Create an instance of PublicClientApplication
6468
app = PublicClientApplication(client_id, authority=authority)
6569

6670
scopes = [
6771
"https://auth.msft.communication.azure.com/Teams.ManageCalls",
6872
"https://auth.msft.communication.azure.com/Teams.ManageChats"
6973
]
74+
75+
# Retrieve the AAD token and object ID of a Teams user
7076
result = app.acquire_token_interactive(scopes)
7177
aad_token = result["access_token"]
7278
user_object_id = result["id_token_claims"]["oid"]
@@ -92,6 +98,7 @@ client = CommunicationIdentityClient.from_connection_string(connection_string)
9298
Use the `get_token_for_teams_user` method to issue an access token for the Teams user that can be used with the Azure Communication Services SDKs.
9399

94100
```python
101+
# Exchange the Azure AD access token of the Teams User for a Communication Identity access token
95102
token_result = client.get_token_for_teams_user(aad_token, client_id, user_object_id)
96103
print("Token: " + token_result.token)
97104
```

0 commit comments

Comments
 (0)