File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change 1
1
from unittest import TestCase
2
2
3
- import adal
3
+ import msal
4
4
from settings import settings
5
5
6
6
from office365 .graph_client import GraphClient
7
7
8
8
9
9
def get_token ():
10
10
"""
11
- Get token
11
+ Acquire token via MSAL ROPC flow!
12
+
12
13
"""
13
14
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
21
23
22
24
23
25
class GraphTestCase (TestCase ):
You can’t perform that action at this time.
0 commit comments