Skip to content

Commit 6d7f9d4

Browse files
committed
GraphClient client refactorings in terms of authentication
1 parent 53eddff commit 6d7f9d4

File tree

158 files changed

+670
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+670
-379
lines changed

examples/auth/interactive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from office365.graph_client import GraphClient
1414
from tests import test_client_id, test_tenant
1515

16-
client = GraphClient.with_token_interactive(test_tenant, test_client_id)
16+
client = GraphClient(tenant=test_tenant).with_token_interactive(test_client_id)
1717
me = client.me.get().execute_query()
1818
print("Welcome, {0}!".format(me.given_name))
1919
site = client.sites.root.get().execute_query()

examples/auth/register_sharepoint_apponly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
from office365.graph_client import GraphClient
1818
from tests import test_client_id, test_password, test_tenant, test_username
1919

20-
admin_client = GraphClient.with_username_and_password(
21-
test_tenant, test_client_id, test_username, test_password
20+
admin_client = GraphClient(tenant=test_tenant).with_username_and_password(
21+
test_client_id, test_username, test_password
2222
)

examples/auth/with_client_secret.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Acquires a token by using application secret
33
44
The following options are supported:
5-
- utilize built in GraphClient.with_client_secret(tenant, client_id, client_secret, scopes, token_cache) method
5+
- utilize built in GraphClient(tenant=tenant).with_client_secret(client_id, client_secret) method
66
- or provide a custom callback function to GraphClient constructor as demonstrated below
77
88
https://learn.microsoft.com/en-us/entra/identity-platform/msal-authentication-flows#client-credentials

examples/auth/with_user_creds.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from office365.graph_client import GraphClient
88
from tests import test_client_id, test_password, test_tenant, test_username
99

10-
client = GraphClient.with_username_and_password(
11-
test_tenant, test_client_id, test_username, test_password
10+
client = GraphClient(tenant=test_tenant).with_username_and_password(
11+
test_client_id, test_username, test_password
1212
)
1313
me = client.me.get().execute_query()
14-
print(me.user_principal_name)
14+
print(me)

examples/communications/create_call.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from office365.graph_client import GraphClient
66
from tests import test_client_id, test_client_secret, test_tenant
77

8-
client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
8+
client = GraphClient(tenant=test_tenant).with_client_secret(
9+
test_client_id, test_client_secret
10+
)
911
call = client.communications.calls.create(
1012
"https://mediadev8.com/teamsapp/api/calling"
1113
).execute_query()

examples/directory/applications/add_cert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
cert_path = "../../selfsigncert.pem"
1414

15-
client = GraphClient.with_username_and_password(
16-
test_tenant, test_client_id, test_username, test_password
15+
client = GraphClient(tenant=test_tenant).with_username_and_password(
16+
test_client_id, test_username, test_password
1717
)
1818
target_app = client.applications.get_by_app_id(test_client_id)
1919
with open(cert_path, "rb") as f:

examples/directory/applications/app_password.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
test_username,
1313
)
1414

15-
client = GraphClient.with_username_and_password(
16-
test_tenant, test_client_id, test_username, test_password
15+
client = GraphClient(tenant=test_tenant).with_username_and_password(
16+
test_client_id, test_username, test_password
1717
)
1818
target_app = client.applications.get_by_app_id(test_client_credentials.clientId)
1919
result = target_app.add_password("Password friendly name").execute_query()

examples/directory/applications/get_by_app_id.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from office365.graph_client import GraphClient
1111
from tests import test_client_id, test_client_secret, test_tenant
1212

13-
client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
13+
client = GraphClient(tenant=test_tenant).with_client_secret(
14+
test_client_id, test_client_secret
15+
)
1416
app = client.applications.get_by_app_id(test_client_id).get().execute_query()
1517
print(app)

examples/directory/applications/grant_application_perms.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
test_tenant,
2323
)
2424

25-
client = GraphClient.with_token_interactive(
26-
test_tenant, test_client_id, test_admin_principal_name
25+
client = GraphClient(tenant=test_tenant).with_token_interactive(
26+
test_client_id, test_admin_principal_name
2727
)
28-
# client = GraphClient.with_client_secret(test_tenant, test_client_id, test_client_secret)
2928

3029
# Step 1: Get the resource service principal
3130
resource = client.service_principals.get_by_name("Microsoft Graph")

examples/directory/applications/grant_delegated_perms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
test_user_principal_name,
1616
)
1717

18-
client = GraphClient.with_token_interactive(
19-
test_tenant, test_client_id, test_admin_principal_name
18+
client = GraphClient(tenant=test_tenant).with_token_interactive(
19+
test_client_id, test_admin_principal_name
2020
)
2121

2222

0 commit comments

Comments
 (0)