Skip to content

Commit 7e51ec8

Browse files
vvgrem@gmail.comvvgrem@gmail.com
authored andcommitted
GraphClient: removed dependency to adal
1 parent 9d4ce57 commit 7e51ec8

21 files changed

+79
-39
lines changed

examples/directory/clear_directory.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import adal
2+
13
from settings import settings
24

35
from office365.graph_client import GraphClient
46

57

6-
def get_token_for_user(auth_ctx):
7-
"""
8-
9-
:type auth_ctx: adal.AuthenticationContext
10-
"""
8+
def get_token_for_user():
9+
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
10+
auth_ctx = adal.AuthenticationContext(authority_url)
1111
token = auth_ctx.acquire_token_with_username_password(
1212
'https://graph.microsoft.com',
1313
settings['user_credentials']['username'],

examples/directory/import_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from settings import settings
33
from tests import random_seed
44

5-
from office365.directory import UserProfile
5+
from office365.directory.userProfile import UserProfile
66
from office365.graph_client import GraphClient
77

88

examples/onedrive/export_files.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import os
22
import tempfile
33

4+
import adal
5+
46
from settings import settings
57

68
from office365.graph_client import GraphClient
79

810

9-
def get_token(auth_ctx):
11+
def get_token():
1012
"""Acquire token via client credential flow (ADAL Python library is utilized)
11-
:type auth_ctx: adal.AuthenticationContext
1213
"""
14+
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
15+
auth_ctx = adal.AuthenticationContext(authority_url)
1316
token = auth_ctx.acquire_token_with_client_credentials(
1417
"https://graph.microsoft.com",
1518
settings['client_credentials']['client_id'],

examples/onedrive/import_files.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import os
22
from os.path import isfile, join
33

4+
import adal
5+
46
from settings import settings
57

68
from office365.graph_client import GraphClient
79

810

9-
def get_token(auth_ctx):
11+
def get_token():
1012
"""Acquire token via client credential flow
11-
12-
:type auth_ctx: adal.AuthenticationContext
1313
"""
14+
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
15+
auth_ctx = adal.AuthenticationContext(authority_url)
1416
token = auth_ctx.acquire_token_with_client_credentials(
1517
"https://graph.microsoft.com",
1618
settings['client_credentials']['client_id'],

examples/onedrive/print_folders_and_files.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import adal
2+
13
from settings import settings
24

35
from office365.graph_client import GraphClient
46

57

6-
def get_token_for_user(auth_ctx):
8+
def get_token_for_user():
79
"""
810
Acquire token via user credentials
9-
10-
:type auth_ctx: adal.AuthenticationContext
1111
"""
12+
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
13+
auth_ctx = adal.AuthenticationContext(authority_url)
1214
token = auth_ctx.acquire_token_with_username_password(
1315
'https://graph.microsoft.com',
1416
settings['user_credentials']['username'],

examples/outlook/send_message.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import adal
2+
13
from settings import settings
24

35
from office365.graph_client import GraphClient
46

57

6-
def get_token(auth_ctx):
8+
def get_token():
79
"""Acquire token via client credential flow (ADAL Python library is utilized)"""
10+
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
11+
auth_ctx = adal.AuthenticationContext(authority_url)
812
token = auth_ctx.acquire_token_with_client_credentials(
913
"https://graph.microsoft.com",
1014
settings['client_credentials']['client_id'],

examples/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
msal~=1.5.0
2+
Faker~=4.1.2
3+

examples/teams/list_teams.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import adal
2+
3+
from settings import settings
4+
from office365.graph_client import GraphClient
5+
6+
7+
def acquire_token():
8+
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
9+
auth_ctx = adal.AuthenticationContext(authority_url)
10+
token = auth_ctx.acquire_token_with_username_password(
11+
'https://graph.microsoft.com',
12+
settings['user_credentials']['username'],
13+
settings['user_credentials']['password'],
14+
settings['client_credentials']['client_id'])
15+
return token
16+
17+
18+
client = GraphClient(settings['tenant'], acquire_token)
19+
teams = client.teams.get_all().execute_query()
20+
for team in teams:
21+
print(team.id)

examples/teams/provision_team.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import uuid
22

3+
import adal
4+
35
from settings import settings
46

57
from office365.directory.groupProfile import GroupProfile
68
from office365.graph_client import GraphClient
79

810

9-
def acquire_token(auth_ctx):
10-
"""
11-
Get token
12-
:type auth_ctx: adal.AuthenticationContext
13-
"""
11+
def acquire_token():
12+
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
13+
auth_ctx = adal.AuthenticationContext(authority_url)
1414
token = auth_ctx.acquire_token_with_username_password(
1515
'https://graph.microsoft.com',
1616
settings['user_credentials']['username'],

generator/builders/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)