Skip to content

Commit 8abc866

Browse files
authored
Merge pull request #21 from MicrosoftDocs/docs-contrib
Update documentation
2 parents 58b13e4 + 4e92d11 commit 8abc866

File tree

7 files changed

+122
-68
lines changed

7 files changed

+122
-68
lines changed

.github/worfklows/linkchecker.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Validate content links
2+
3+
on:
4+
push:
5+
repository_dispatch:
6+
workflow_dispatch:
7+
schedule:
8+
- cron: "00 18 * * *"
9+
10+
jobs:
11+
linkChecker:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Link Checker
17+
id: lychee
18+
uses: lycheeverse/lychee-action@v1.6.1
19+
env:
20+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
21+
with:
22+
args: --verbose --exclude-file .lycheeignore --no-progress './**/*.md' --exclude-mail
23+
fail: true
24+
25+
- name: Create Issue From File
26+
if: always() && env.lychee_exit_code != 0 && github.event_name != 'pull_request'
27+
uses: peter-evans/create-issue-from-file@v4
28+
with:
29+
title: Link Checker Report
30+
content-filepath: ./lychee/out.md
31+
labels: report, automated issue

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# Microsoft Authentication Library (MSAL) for Python Documentation
2+
3+
[![Validate content links](https://github.com/MicrosoftDocs/microsoft-authentication-library-for-python/actions/workflows/linkchecker.yml/badge.svg)](https://github.com/MicrosoftDocs/microsoft-authentication-library-for-python/actions/workflows/linkchecker.yml)
4+
5+
This is the documentation repository for Microsoft Authentication Library (MSAL) for .NET. If you are looking for the library, refer to [AzureAD/microsoft-authentication-library-for-python](https://github.com/AzureAD/microsoft-authentication-library-for-python).
6+
7+
## Contributions
8+
9+
Contributions to our documentation are welcome. Make sure to familiarize yourself with the [Microsoft Writing Style Guide](https://learn.microsoft.com/style-guide/welcome/) and the [Contributor Guide](https://learn.microsoft.com/contribute/) before making any changes.
10+
11+
> **Warning**
12+
> **Do not** modify any YML files in the `python/docs-ref-autogen` folder - those are generated automatically from the library source code and any changes will be automatically overwritten the next time the documentation Continuous Integration (CI) job runs. To make changes to any API docs you will need to open a pull request in the [AzureAD/microsoft-authentication-library-for-python](https://github.com/AzureAD/microsoft-authentication-library-for-python) repository.
13+
14+
If you would like to author an entirely new document (e.g., for a new scenario), make sure to [open an issue](https://github.com/MicrosoftDocs/microsoft-authentication-library-for-python/issues) first. This will allow the engineering team to discuss the proposed changes and ensure that it won't be overwritten by future changes.
15+
16+
## API reference documentation automation
17+
18+
Continuous Integration (CI) jobs for this repository are available in the [automation Azure DevOps instance](https://apidrop.visualstudio.com/Content%20CI/_build?definitionId=5247).
19+
20+
>**Note**
21+
>The changes from the CI job will always be pushed to the `smoke-test` branch first. To propagate them to production, merge the changes into `main`, and then merge `main` to `live`. Ensure that all checks pass before merging changes.
22+
123
## Microsoft Open Source Code of Conduct
24+
225
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
3-
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
26+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

msal-python-conceptual/TOC.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
href: getting-started/why-use-msal-python.md
66
- name: Register your app with Azure AD
77
href: /azure/active-directory/develop/active-directory-integrating-applications
8-
- name: Scenarios
9-
href: getting-started/scenarios.md
108
- name: Client applications
119
href: getting-started/client-applications.md
1210
- name: Acquiring tokens

msal-python-conceptual/getting-started/acquiring-tokens.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,34 @@ description: "There are many ways of acquiring a token. Some require user intera
55

66
# Acquiring tokens
77

8-
As explained in [scenarios](./scenarios.md), there are many ways of acquiring a token. Some require user interaction through a web browser. Some don't require any user interaction.
9-
In general the way to acquire a token is different depending on the application type- public client application (Desktop / Mobile) or a confidential client application (Web App, Web API, daemon application like a windows service)
8+
As explained in [MSAL Python usage scenarios](../index.md#usage-scenarios), there are many ways of acquiring a token. Some require user interaction through a web browser, while others don't require any user interaction at all.
109

1110
## Prerequisites
1211

13-
Before acquiring tokens with MSAL Python:
14-
15-
- Instantiate a [client application](./client-applications.md)
12+
Before acquiring tokens with MSAL Python, make sure to instantiate a [client application](./client-applications.md)
1613

1714
## Token acquisition methods
1815

19-
Follow the topics below for detailed explanation with MSAL Python code usage for each token acquisition method.
16+
The approach to acquiring a token is different depending on the application type - public client applications (desktop and mobile) or confidential client application (web app, web API, or a daemon application like a Windows service). Each of the individual approaches is described below.
2017

2118
### Public client applications
2219

23-
- Acquire tokens by [authorization code](/azure/active-directory/develop/scenario-desktop-acquire-token?tabs=python#acquiring-a-token-interactively) after letting the user sign-in through the authorization request URL.
20+
Public client applications cannot securely store a secret and can _only_ authenticate the user that is interacting with the product. MSAL Python exposes most of the token acquisition logic for public applications through [`PublicClientApplication`](xref:msal.application.PublicClientApplication). Using this class enables developers to:
21+
22+
- Acquire tokens **as the user** with the help of an [interactive flow](/azure/active-directory/develop/scenario-desktop-acquire-token?tabs=python#acquiring-a-token-interactively) after letting the user sign-in through the authorization request URL.
2423
- It's also possible (but not recommended) to get a token with a [username and password](/azure/active-directory/develop/scenario-desktop-acquire-token?tabs=python#username--password).
25-
- Finally, for applications running on devices which don't have a web browser, it's possible to acquire a token through the [device code flow](/azure/active-directory/develop/scenario-desktop-acquire-token?tabs=python#command-line-tool-without-web-browser), which provides the user with a URL and a code. The user goes to a web browser on another device, enters the code and signs-in, and then Azure AD returns back a token to the browser-less device.
24+
- For applications running on devices which don't have a web browser, it's possible to acquire a token through the [device code flow](/azure/active-directory/develop/scenario-desktop-acquire-token?tabs=python#command-line-tool-without-web-browser), which provides the user with a URL and a code. The user goes to a web browser on another device, enters the code and signs in. On successful authentication, Azure AD will return a token to the browser-less device.
2625

2726
### Confidential client applications
2827

29-
- Acquire token **as the application itself** using [client credentials](/azure/active-directory/develop/scenario-daemon-acquire-token?tabs=python#acquiretokenforclient-api), and not for a user. For example, in apps which process users in batches and not a particular user such as in syncing tools.
30-
- In the case of Web Apps or Web APIs **calling another downstream Web API in the name of the user**, use the [On Behalf Of flow](/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow) to acquire a token based on some User assertion (SAML for instance, or a JWT token).
31-
- **For Web apps in the name of a user**, acquire tokens by [authorization code](/azure/active-directory/develop/scenario-web-app-call-api-acquire-token?tabs=python) after letting the user sign-in through the authorization request URL. This is typically the mechanism used by an application which lets the user sign-in using Open ID Connect, but then wants to access Web APIs for this particular user.
28+
Confidential client applications can securely store a secret and can authenticate both on behalf of an application as well as on behalf of a given user. With MSAL Python, developers can use [`ConfidentialClientApplication`](xref:msal.application.ConfidentialClientApplication) to access confidential client application capabilities, such as:
29+
30+
- Acquire token **as the application itself** using [client credentials](/azure/active-directory/develop/scenario-daemon-acquire-token?tabs=python#acquiretokenforclient-api), and not for a user. For example, this can be used in applications which process users in batches and not one particular user, such as syncing tools.
31+
- In the case of web Apps or web APIs **calling another downstream Web API in the name of the user**, use the [On Behalf Of flow](/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow) to acquire a token based on a user assertion (e.g., SAML, JWT).
32+
- **For Web apps authenticating in the name of a user**, acquire tokens through [authorization code](/azure/active-directory/develop/scenario-web-app-call-api-acquire-token?tabs=python) after letting the user sign-in through the authorization request URL. This is typically the mechanism used by an application which lets the user sign-in using Open ID Connect but then wants to access Web APIs for this particular user.
3233

33-
## MSAL Python caches tokens
34+
## MSAL Python token caching
3435

35-
For both Public client and Confidential client applications, MSAL maintains a token cache, and applications should try to get a token from the cache first before any other means. Take a look at the [recommended pattern](/azure/active-directory/develop/scenario-desktop-acquire-token?tabs=python) for token acquisition.
36+
Both public and confidential client applications support token caching, handled direclt by MSAL Python. Applications should try to get a token from the cache first before relying on any other means. Take a look at the [recommended token acquisition pattern](/azure/active-directory/develop/scenario-desktop-acquire-token?tabs=python) to learn more.
3637

37-
To be able to make use of the cache, the application needs to customize the [token cache serialization](/azure/active-directory/develop/msal-python-token-cache-serialization).
38+
To be able to persist the cache, the developers will need to configure the [token cache serialization](/azure/active-directory/develop/msal-python-token-cache-serialization) logic.

msal-python-conceptual/getting-started/client-applications.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,33 @@ description: "How to instantiate client applications in MSAL Python."
1111

1212
Before instantiating your app with MSAL Python:
1313

14-
1. Understand the types of Client applications available- [Public Client and Confidential Client applications](/azure/active-directory/develop/msal-client-applications).
15-
1. You'll need to [register](/azure/active-directory/develop/quickstart-register-app) the application with Azure AD. You will therefore know:
16-
- Its `client_id` (a string representing a GUID)
17-
- The identity provider URL (named the instance) and the sign-in audience for your application. These two parameters are collectively known as the authority.
18-
- Possibly the `Tenant+id` in the case you are writing a line of business application (just for your organization, also named single-tenant application)
19-
- In case it's a confidential client app, its application secret (`client_secret` string) or certificate
20-
- For web apps, you'll have also set the `redirect_uri` where the identity provider will contact back your application with the security tokens.
14+
1. Understand the types of client applications available - [Public Client and Confidential Client applications](/azure/active-directory/develop/msal-client-applications).
15+
1. You'll need to [register the application](/azure/active-directory/develop/quickstart-register-app) with Azure AD. From the registration page, you will need:
16+
- The application client identifier (a string in the form of a GUID)
17+
- The identity provider URL (the instance) and the sign-in audience for your application. These two parameters are collectively known as the **authority**.
18+
- If necessary, the tenant identifier (also a GUID) in case you are writing a line of business application scoped to just your organization (also known as a single-tenant application).
19+
- If you are building a confidential client app, you will need to create an application secret in the form of a string or certificate.
20+
- For web applications, you'll have also set the redirect URL that Azure AD will use to return the code.
2121

2222
### Instantiating a public client application
2323

24+
Public client applications use the [`PublicClientApplication`](xref:msal.application.PublicClientApplication) class.
25+
2426
```python
2527
app = msal.PublicClientApplication(
26-
config["client_id"],
27-
authority=config["authority"],
28+
"client_id",
29+
authority="authority",
2830
)
2931
```
3032

3133
### Instantiating a confidential client application
3234

35+
Confidential client applications use the [`ConfidentialClientApplication`](xref:msal.application.ConfidentialClientApplication) class.
36+
3337
```python
3438
app = msal.ConfidentialClientApplication(
35-
config["client_id"],
36-
authority=config["authority"],
37-
client_credential=config["client_secret"],
38-
)
39+
"client_id",
40+
authority="authority",
41+
client_credential="client_secret",
42+
)
3943
```

msal-python-conceptual/getting-started/scenarios.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)