-
-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduced authentication context for graph client, a few fixes for o…
…nedrive tests
- Loading branch information
Showing
10 changed files
with
281 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Username Password Authentication flow | ||
https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Username-Password-Authentication | ||
""" | ||
|
||
import msal | ||
|
||
from office365.graph_client import GraphClient | ||
from tests import test_client_id, test_tenant, test_user_credentials | ||
|
||
|
||
def acquire_token(): | ||
authority_url = "https://login.microsoftonline.com/{0}".format(test_tenant) | ||
app = msal.PublicClientApplication( | ||
authority=authority_url, client_id=test_client_id | ||
) | ||
|
||
result = app.acquire_token_by_username_password( | ||
username=test_user_credentials.userName, | ||
password=test_user_credentials.password, | ||
scopes=["https://graph.microsoft.com/.default"], | ||
) | ||
return result | ||
|
||
|
||
client = GraphClient(acquire_token) | ||
me = client.me.get().execute_query() | ||
print(me.user_principal_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.