Skip to content

Commit 4da5d3f

Browse files
vvgrem@gmail.comvvgrem@gmail.com
authored andcommitted
Unit tests: ADAL -> MSAL
1 parent e17515d commit 4da5d3f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

tests/graph_case.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
from unittest import TestCase
22

3-
import adal
3+
import msal
44
from settings import settings
55

66
from office365.graph_client import GraphClient
77

88

99
def get_token():
1010
"""
11-
Get token
11+
Acquire token via MSAL ROPC flow!
12+
1213
"""
1314
authority_url = 'https://login.microsoftonline.com/{0}'.format(settings['tenant'])
14-
auth_ctx = adal.AuthenticationContext(authority_url)
15-
token = auth_ctx.acquire_token_with_username_password(
16-
'https://graph.microsoft.com',
17-
settings['user_credentials']['username'],
18-
settings['user_credentials']['password'],
19-
settings['client_credentials']['client_id'])
20-
return token
15+
app = msal.PublicClientApplication(
16+
authority=authority_url,
17+
client_id=settings.get('client_credentials').get('client_id')
18+
)
19+
result = app.acquire_token_by_username_password(username=settings.get('user_credentials').get('username'),
20+
password=settings.get('user_credentials').get('password'),
21+
scopes=["https://graph.microsoft.com/.default"])
22+
return result
2123

2224

2325
class GraphTestCase(TestCase):

0 commit comments

Comments
 (0)