Skip to content

Commit 2abfe27

Browse files
committed
Add client id and tenant_id on interactive browser instantiation
1 parent 9489e52 commit 2abfe27

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ credential = ClientSecretCredential(
121121
'client_id',
122122
'client_secret'
123123
)
124-
scopes = ['https://graph.microsoft.com/.default']
124+
scopes = ["User.ReadWrite"]
125125
client = GraphServiceClient(credentials=credential, scopes=scopes)
126126

127127
# GET /users/{id | userPrincipalName}
@@ -139,8 +139,11 @@ import asyncio
139139
from azure.identity import InteractiveBrowserCredential
140140
from msgraph import GraphServiceClient
141141

142-
credential = InteractiveBrowserCredential()
143-
scopes = ['https://graph.microsoft.com/.default']
142+
credential = InteractiveBrowserCredential(
143+
client_id=os.getenv('client_id'),
144+
tenant_id=os.getenv('tenant_id'),
145+
)
146+
scopes = ["User.ReadWrite"]
144147
client = GraphServiceClient(credentials=credential, scopes=scopes,)
145148

146149
# GET /me

docs/authentication_samples.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ credential = DeviceCodeCredential(
1414
tenant_id='TENANT_ID',
1515
)
1616

17-
scopes = ['https://graph.microsoft.com/.default']
17+
scopes = ["User.ReadWrite"]
1818

1919
# Create an API client with the credentials and scopes.
2020
client = GraphServiceClient(credentials=credential, scopes=scopes)
@@ -35,8 +35,12 @@ from azure.identity import InteractiveBrowserCredential
3535
from msgraph import GraphServiceClient
3636

3737
# Create a credential object. Used to authenticate requests
38-
credential = InteractiveBrowserCredential()
39-
scopes = ['https://graph.microsoft.com/.default']
38+
credentials = InteractiveBrowserCredential(
39+
client_id=os.getenv('client_id'),
40+
tenant_id=os.getenv('tenant_id'),
41+
)
42+
43+
scopes = ["User.ReadWrite"]
4044

4145
# Create an API client with the credentials and scopes.
4246
client = GraphServiceClient(credentials=credential, scopes=scopes)

0 commit comments

Comments
 (0)