Skip to content

Commit 5cfe977

Browse files
Merge pull request #96229 from MicrosoftDocs/master
Merge master to live 4:15 AM
2 parents 2d3740e + f75be94 commit 5cfe977

File tree

323 files changed

+4096
-2717
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

323 files changed

+4096
-2717
lines changed

articles/active-directory/develop/TOC.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@
241241
href: migrate-android-adal-msal.md
242242
- name: Migrate to MSAL.iOS and MacOS
243243
href: migrate-objc-adal-msal.md
244-
- name: Migrate to MSAL Java
244+
- name: Migrate to MSAL Python
245+
href: migrate-python-adal-msal.md
246+
- name: Migrate to MSAL for Java
245247
href: migrate-adal-msal-java.md
246248
- name: Migrate Xamarin apps using brokers from ADAL.NET to MSAL.NET
247249
href: msal-net-migration-ios-broker.md
@@ -452,7 +454,11 @@
452454
href: request-custom-claims.md
453455
- name: Redirect URI configuration
454456
href: redirect-uris-ios.md
455-
- name: MSAL Java
457+
- name: MSAL for Python
458+
items:
459+
- name: Token cache serialization
460+
href: msal-python-token-cache-serialization.md
461+
- name: MSAL for Java
456462
items:
457463
- name: Token cache serialization
458464
href: msal-java-token-cache-serialization.md

articles/active-directory/develop/migrate-adal-msal-java.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
title: ADAL to MSAL migration guide for Java- Microsoft identity platform | Azure
2+
title: ADAL to MSAL migration guide for Java | Azure
3+
titleSuffix: Microsoft identity platform
34
description: Learn how to migrate your Azure Active Directory Authentication Library (ADAL) Java app to the Microsoft Authentication Library (MSAL).
45
services: active-directory
56
author: sangonzal
@@ -64,7 +65,7 @@ The following table shows how ADAL4J functions map to the new MSAL4J functions:
6465

6566
ADAL4J manipulated users. Although a user represents a single human or software agent, it can have one or more accounts in the Microsoft identity system. For example, a user may have several Azure AD, Azure AD B2C, or Microsoft personal accounts.
6667

67-
MSAL4J defines the concept of Account via the `IAccount` interface. This is a breaking change from ADAL4J, but it is a good one because it captures the fact that that the same user can have several accounts, and perhaps even in different Azure AD directories. MSAL4J provides better information in guest scenarios because home account information is provided.
68+
MSAL4J defines the concept of Account via the `IAccount` interface. This is a breaking change from ADAL4J, but it is a good one because it captures the fact that the same user can have several accounts, and perhaps even in different Azure AD directories. MSAL4J provides better information in guest scenarios because home account information is provided.
6869

6970
## Cache persistence
7071

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: ADAL to MSAL migration guide for Python | Azure
3+
description: Learn how to migrate your Azure Active Directory Authentication Library (ADAL) Python app to the Microsoft Authentication Library (MSAL) for Python.
4+
services: active-directory
5+
titleSuffix: Microsoft identity platform
6+
author: rayluo
7+
manager: henrikm
8+
editor: twhitney
9+
10+
ms.service: active-directory
11+
ms.subservice: develop
12+
ms.devlang: na
13+
ms.topic: conceptual
14+
ms.tgt_pltfrm: Python
15+
ms.workload: identity
16+
ms.date: 11/11/2019
17+
ms.author: rayluo
18+
ms.reviewer:
19+
ms.custom: aaddev
20+
#Customer intent: As a Python application developer, I want to learn how to migrate my v1 ADAL app to v2 MSAL.
21+
ms.collection: M365-identity-device-management
22+
---
23+
24+
# ADAL to MSAL migration guide for Python
25+
26+
This article highlights changes you need to make to migrate an app that uses the Azure Active Directory Authentication Library (ADAL) to use the Microsoft Authentication Library (MSAL).
27+
28+
## Difference highlights
29+
30+
ADAL works with the Azure Active Directory v1.0 endpoint. The Microsoft Authentication Library (MSAL) works with the Microsoft identity platform--formerly known as the Azure Active Directory v2.0 endpoint. The Microsoft identity platform differs from Azure Active Directory v1.0 in that it:
31+
32+
Supports:
33+
- Work and school accounts (Azure AD provisioned accounts)
34+
- Personal accounts (such as Outlook.com or Hotmail.com)
35+
- Your customers who bring their own email or social identity (such as LinkedIn, Facebook, Google) via the Azure AD B2C offering
36+
37+
- Is standards compatible with:
38+
- OAuth v2.0
39+
- OpenID Connect (OIDC)
40+
41+
See [What's different about the Microsoft identity platform (v2.0) endpoint?](https://docs.microsoft.com/azure/active-directory/develop/azure-ad-endpoint-comparison) for more details.
42+
43+
### Scopes not resources
44+
45+
ADAL Python acquires tokens for resources, but MSAL Python acquires tokens for scopes. The API surface in MSAL Python does not have resource parameter anymore. You would need to provide scopes as a list of strings that declare the desired permissions and resources that are requested. To see some example of scopes, see [Microsoft Graph's scopes](https://docs.microsoft.com/graph/permissions-reference).
46+
47+
### Error handling
48+
49+
Azure Active Directory Authentication Library (ADAL) for Python uses the exception `AdalError` to indicate that there's been a problem. MSAL for Python typically uses error codes, instead. For more information, see [MSAL for Python error handling](msal-handling-exceptions.md#msal-for-python-error-handling).
50+
51+
### API changes
52+
53+
The following table lists an API in ADAL for Python, and the one to use in its place in MSAL for Python:
54+
55+
| ADAL for Python API | MSAL for Python API |
56+
| ------------------- | ---------------------------------- |
57+
| [AuthenticationContext](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext) | [PublicClientApplication or ConfidentialClientApplication](https://msal-python.readthedocs.io/en/latest/#msal.ClientApplication.__init__) |
58+
| N/A | [get_authorization_request_url()](https://msal-python.readthedocs.io/en/latest/#msal.ClientApplication.get_authorization_request_url) |
59+
| [acquire_token_with_authorization_code()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.acquire_token_with_authorization_code) | [acquire_token_by_authorization_code()](https://msal-python.readthedocs.io/en/latest/#msal.ClientApplication.acquire_token_by_authorization_code) |
60+
| [acquire_token()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.acquire_token) | [acquire_token_silent()](https://msal-python.readthedocs.io/en/latest/#msal.ClientApplication.acquire_token_silent) |
61+
| [acquire_token_with_refresh_token()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.acquire_token_with_refresh_token) | N/A (See the section above) |
62+
| [acquire_user_code()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.acquire_user_code) | [initiate_device_flow()](https://msal-python.readthedocs.io/en/latest/#msal.PublicClientApplication.initiate_device_flow) |
63+
| [acquire_token_with_device_code()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.acquire_token_with_device_code) and [cancel_request_to_get_token_with_device_code()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.cancel_request_to_get_token_with_device_code) | [acquire_token_by_device_flow()](https://msal-python.readthedocs.io/en/latest/#msal.PublicClientApplication.acquire_token_by_device_flow) |
64+
| [acquire_token_with_username_password()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.acquire_token_with_username_password) | [acquire_token_by_username_password()](https://msal-python.readthedocs.io/en/latest/#msal.PublicClientApplication.acquire_token_by_username_password) |
65+
| [acquire_token_with_client_credentials()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.acquire_token_with_client_credentials) and [acquire_token_with_client_certificate()](https://adal-python.readthedocs.io/en/latest/#adal.AuthenticationContext.acquire_token_with_client_certificate) | [acquire_token_for_client()](https://msal-python.readthedocs.io/en/latest/#msal.ConfidentialClientApplication.acquire_token_for_client) |
66+
| N/A | [acquire_token_on_behalf_of()](https://msal-python.readthedocs.io/en/latest/#msal.ConfidentialClientApplication.acquire_token_on_behalf_of) |
67+
| [TokenCache()](https://adal-python.readthedocs.io/en/latest/#adal.TokenCache) | [SerializableTokenCache()](https://msal-python.readthedocs.io/en/latest/#msal.SerializableTokenCache) |
68+
| N/A | Cache with persistence, available from [MSAL Extensions](https://github.com/marstr/original-microsoft-authentication-extensions-for-python) |
69+
70+
## Migrate existing refresh tokens for MSAL Python
71+
72+
The Microsoft authentication library (MSAL) abstracts the concept of refresh tokens. MSAL Python provides an in-memory token cache by default so that you don't need to store, lookup, or update refresh tokens. Users will also see fewer sign-in prompts because refresh tokens can usually be updated without user intervention. For more information about the token cache, see [Custom token cache serialization in MSAL for Python](msal-python-token-cache-serialization.md).
73+
74+
The following code will help you migrate your refresh tokens managed by another OAuth2 library (including but not limited to ADAL Python) to be managed by MSAL for Python. One reason for migrating those refresh tokens is to prevent existing users from needing to sign in again when you migrate your app to MSAL for Python.
75+
76+
The method for migrating a refresh token is to use MSAL for Python to acquire a new access token using the previous refresh token. When the new refresh token is returned, MSAL for Python will store it in the cache. Here is an example of how to do it:
77+
78+
```python
79+
from msal import PublicClientApplication
80+
81+
def get_preexisting_rt_and_their_scopes_from_elsewhere(...):
82+
raise NotImplementedError("You will need to implement this by yourself")
83+
84+
app = PublicClientApplication(..., token_cache=...)
85+
86+
for old_rt, old_scope in get_preexisting_rt_and_their_scopes_from_elsewhere(...):
87+
# Assuming the old scope could be a space-delimited string.
88+
# MSAL expects a list, like ["scope1", "scope2"].
89+
scopes = old_scope.split()
90+
# If your old refresh token came from ADAL for Python, which uses a resource rather than a scope,
91+
# you need to convert your v1 resource into v2 scopes
92+
# See https://docs.microsoft.com/azure/active-directory/develop/azure-ad-endpoint-comparison#scopes-not-resources
93+
# You may be able to append "/.default" to your v1 resource to form a scope
94+
# See https://docs.microsoft.com/azure/active-directory/develop/v2-permissions-and-consent#the-default-scope
95+
96+
result = app.client.obtain_token_by_refresh_token(old_rt, scope=scopes)
97+
# When this call returns the new token(s), a new refresh token is issued by the Microsoft identity platform and MSAL for Python
98+
# stores it in the token cache.
99+
```
100+
101+
## Next steps
102+
103+
For more information, refer to [v1.0 and v2.0 comparison](active-directory-v2-compare.md).

articles/active-directory/develop/msal-handling-exceptions.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ms.devlang: na
1414
ms.topic: conceptual
1515
ms.tgt_pltfrm: na
1616
ms.workload: identity
17-
ms.date: 09/08/2019
17+
ms.date: 11/13/2019
1818
ms.author: twhitney
1919
ms.reviewer: saeeda
2020
ms.custom: aaddev
@@ -36,7 +36,7 @@ During silent or interactive token acquisition, apps may come across errors duri
3636

3737
The complete list of errors is listed in [MSALError enum](https://github.com/AzureAD/microsoft-authentication-library-for-objc/blob/master/MSAL/src/public/MSALError.h#L128).
3838

39-
All MSAL produced errors are returned with `MSALErrorDomain` domain.
39+
All MSAL produced errors are returned with `MSALErrorDomain` domain.
4040

4141
For system errors, MSAL returns the original `NSError` from the system API. For example, if token acquisition fails because of a lack of network connectivity, MSAL returns an error with the `NSURLErrorDomain` domain and `NSURLErrorNotConnectedToInternet` code.
4242

@@ -238,6 +238,17 @@ Swift
238238
application.acquireTokenSilent(with: silentParameters, completionBlock: completionBlock)
239239
```
240240

241+
## MSAL for Python error handling
242+
243+
In MSAL for Python, most errors are conveyed as a return value from the API call. The error is represented as a dictionary containing the JSON response from the Microsoft identity platform.
244+
245+
* A successful response contains the `"access_token"` key. The format of the response is defined by the OAuth2 protocol. For more information, see [5.1 Successful Response](https://tools.ietf.org/html/rfc6749#section-5.1)
246+
* An error response contains `"error"` and usually `"error_description"`. The format of the response is defined by the OAuth2 protocol. For more information, see [5.2 Error Response](https://tools.ietf.org/html/rfc6749#section-5.2)
247+
248+
When an error is returned, the `"error_description"` key contains a human-readable message; which in turn typically contains a Microsoft identity platform error code. For details about the various error codes, see [Authentication and authorization error codes](https://docs.microsoft.com/azure/active-directory/develop/reference-aadsts-error-codes).
249+
250+
In MSAL for Python, exceptions are rare because most errors are handled by returning an error value. The `ValueError` exception is only thrown when there is an issue with how you are attempting to use the library--such as when API parameter(s) are malformed.
251+
241252
## .NET exceptions
242253

243254
When processing exceptions, you can use the exception type itself and the `ErrorCode` member to distinguish between exceptions. `ErrorCode` values are constants of type [MsalError](/dotnet/api/microsoft.identity.client.msalerror?view=azure-dotnet).
@@ -341,7 +352,6 @@ catch (MsalUiRequiredException ex) when (ex.ErrorCode == MsalError.InvalidGrantE
341352
}
342353
```
343354

344-
345355
## JavaScript errors
346356

347357
MSAL.js provides error objects that abstract and classify the different types of common errors. It also provides interface to access specific details of the errors such as error messages to handle them appropriately.

articles/active-directory/develop/msal-java-token-cache-serialization.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Custom token cache serialization in MSAL for Java
33
titleSuffix: Microsoft identity platform
4-
description: Learn how to serializing the token cache for MSAL for Java
4+
description: Learn how to serialize the token cache for MSAL for Java
55
services: active-directory
66
documentationcenter: dev-center-name
77
author: sangonzal
@@ -18,13 +18,14 @@ ms.date: 11/07/2019
1818
ms.author: sagonzal
1919
ms.reviewer: navyasri.canumalla
2020
ms.custom: aaddev
21-
#Customer intent: As an application developer using the Microsoft Authentication Library for Java (MSAL4J), I want to learn how to persist the token cache.
21+
#Customer intent: As an application developer using the Microsoft Authentication Library for Java (MSAL4J), I want to learn how to persist the token cache so that it is available to a new instance of my application.
22+
2223
ms.collection: M365-identity-device-management
2324
---
2425

2526
# Custom token cache serialization in MSAL for Java (MSAL4J)
2627

27-
To have a persistent token cache application, you will need to customize the serialization. The Java classes and interfaces involved in token cache serialization are the following:
28+
To persist the token cache between instances of your application, you will need to customize the serialization. The Java classes and interfaces involved in token cache serialization are the following:
2829

2930
- [ITokenCache](https://static.javadoc.io/com.microsoft.azure/msal4j/0.5.0-preview/com/microsoft/aad/msal4j/ITokenCache.html): Interface representing security token cache.
3031
- [ITokenCacheAccessAspect](https://static.javadoc.io/com.microsoft.azure/msal4j/0.5.0-preview/com/microsoft/aad/msal4j/ITokenCacheAccessAspect.html): Interface representing operation of executing code before and after access. You would @Override *beforeCacheAccess* and *afterCacheAccess* with the logic responsible for serializing and deserializing the cache.

0 commit comments

Comments
 (0)