-
Notifications
You must be signed in to change notification settings - Fork 17
Update documentation #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a88f546
Update the documentation
localden 1713393
Make sure that animated GIFs are imported
localden 6310789
Update docfx.json
localden fe32326
Update redirect-urls.png
localden 08c9edf
Add some additional clarification
localden 1566109
Remove unnecessary document
localden def977f
Remove redundant doc
localden f87881d
WAM docs
localden a0cbbec
Add some additional WAM context
localden 1d85cc2
Update WAM docs
localden d6932a3
Typo fix
localden 9d5de49
Update wam.md
localden 4790c08
Update wam.md
localden eb98ae6
Update wam.md
localden ff71a81
Update msal-python-conceptual/advanced/wam.md
localden c38b79d
Update index.md
localden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,97 @@ | ||
| --- | ||
| title: Using MSAL Python with Web Account Manager | ||
| description: "If you are building a Windows application, you might consider simplifying how users authenticate with the help of an authentication broker - the Web Account Manager." | ||
| --- | ||
|
|
||
| # Using MSAL Python with Web Account Manager | ||
|
|
||
| If you are building a Windows application, you might consider simplifying how users authenticate with the help of an _authentication broker_ - the [Web Account Manager](/windows/uwp/security/web-account-manager) (WAM). | ||
|
|
||
| >[!NOTE] | ||
| >WAM is only available on Windows 10 and above, as well as Windows Server 2019 and above. | ||
|
|
||
| To learn more about the benefits of using an authentication broker, refer to [What is a broker](/entra/msal/dotnet/acquiring-tokens/desktop-mobile/wam#what-is-a-broker) in the MSAL.NET documentation. | ||
|
|
||
| ## Usage | ||
|
|
||
| To use the broker, you will need to install the broker-related packages in addition to the core MSAL from PyPI: | ||
|
|
||
| ```bash | ||
| pip install msal[broker]>=1.20,<2 | ||
| ``` | ||
|
|
||
| >[!IMPORTANT] | ||
| >If broker-related packages are not installed and you will try to use the authentication broker, you will get an error: `ImportError: You need to install dependency by: pip install "msal[broker]>=1.20,<2"`. | ||
|
|
||
| Next, you will need to instantiate a new [`PublicClientApplication`](xref:msal.application.PublicClientApplication) and set `allow_broker` to `True`. This will ensure that MSAL will try and communicate with WAM instead of popping up a new browser window. | ||
|
|
||
| ```python | ||
| from msal import PublicClientApplication | ||
|
|
||
| app = PublicClientApplication( | ||
| "CLIENT_ID", | ||
| authority="https://login.microsoftonline.com/common", | ||
| allow_broker=True) | ||
| ``` | ||
|
|
||
| You can now acquire a token by calling [`acquire_token_interactive`](xref:msal.application.PublicClientApplication.acquire_token_interactive) and specifying a parent window handle through `parent_window_handle`: | ||
|
|
||
| ```python | ||
| result = app.acquire_token_interactive(["User.ReadBasic.All"], | ||
| parent_window_handle=app.CONSOLE_WINDOW_HANDLE) | ||
| ``` | ||
|
|
||
| A parent window handle is required by WAM to ensure that the dialog is shown correctly on top of the requesting window. MSAL does not infer this directly due to the fact that there are many variables that might influence what window WAM needs to bind to, and developers building applications are best suited to decide what window that should be. | ||
|
|
||
| For console applications, MSAL makes it easy by offering an out-of-the-box solution to getting the window handle for the terminal - [`CONSOLE_WINDOW_HANDLE`](xref:msal.application.PublicClientApplication.CONSOLE_WINDOW_HANDLE). For desktop applications, additional work with the Windows API might be required to [get the window handle](/windows/apps/develop/ui-input/retrieve-hwnd). Helper packages, like [pywin32](https://pypi.org/project/pywin32/) can help with API calls. | ||
|
|
||
| Before executing your application, make sure that you configure the redirect URL for the desktop app: | ||
|
|
||
| >[!IMPORTANT] | ||
| >To use the Windows broker, your application needs to have the correct redirect URL configured in the Azure Portal, in the shape of: | ||
| > | ||
| >```bash | ||
| >ms-appx-web://microsoft.aad.brokerplugin/YOUR_CLIENT_ID | ||
| >``` | ||
| > | ||
| >If the redirect URL is not configured, you will get a `broker_error` similar to `(pii). Status: Response_Status.Status_ApiContractViolation, Error code: 3399614473, Tag: 557973642`. | ||
|
|
||
| If configuration and instantiation was correct, once you run the application you should see the authentication broker kick in and allow the user to select the account they want to authenticate with. | ||
|
|
||
|  | ||
|
|
||
| Worth noting that if you switch to using broker-based authentication, if the user was previously logged in and the signed-in state is still valid, calling [`acquire_token_interactive`](xref:msal.application.PublicClientApplication.acquire_token_interactive) will still result in a silent attempt to acquire a token, and only prompt when necessary. If you prefer to always prompt, you can use this optional parameter `prompt="select_account"`. | ||
|
|
||
| ## Broker experience differences | ||
|
|
||
| Depending on the authority specified when instantiating [`PublicClientApplication`](xref:msal.application.PublicClientApplication), the broker user interface may be different. | ||
|
|
||
| ### `/consumers` | ||
|
|
||
| Used for authenticating **only** with personal Microsoft accounts. | ||
|
|
||
|  | ||
|
|
||
| ### `/common` | ||
|
|
||
| Used for authenticating with personal Microsoft accounts as well as work and school accounts. | ||
|
|
||
|  | ||
|
|
||
| ### `/organizations` | ||
|
|
||
| Used for authenticating **only** with work and school accounts. | ||
|
|
||
|  | ||
|
|
||
| >[!NOTE] | ||
| >If `login_hint` is provided but the account is not yet registered in WAM, the hint will be automatically filled in the "Email or phone" field. | ||
|
|
||
| ### `/TENANT_ID` | ||
|
|
||
| Used for authenticating **only** with work and school accounts within the specified tenant. | ||
|
|
||
|  | ||
|
|
||
| >[!NOTE] | ||
| >If `login_hint` is provided but the account is not yet registered in WAM, the hint will be automatically filled in the "Email or phone" field. |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -25,7 +25,8 @@ | |
| { | ||
| "files": [ | ||
| "**/*.png", | ||
| "**/*.jpg" | ||
| "**/*.jpg", | ||
| "**/*.gif" | ||
| ], | ||
| "exclude": [ | ||
| "**/obj/**", | ||
|
|
||
This file contains hidden or 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
22 changes: 0 additions & 22 deletions
22
msal-python-conceptual/getting-started/call-protected-web-api.md
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
37 changes: 0 additions & 37 deletions
37
msal-python-conceptual/getting-started/why-use-msal-python.md
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -54,7 +54,8 @@ | |
| { | ||
| "files": [ | ||
| "**/*.png", | ||
| "**/*.jpg" | ||
| "**/*.jpg", | ||
| "**/*.gif" | ||
| ], | ||
| "exclude": [ | ||
| "**/obj/**", | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.