You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/azure/sdk/authentication/additional-methods.md
+81-31Lines changed: 81 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,25 +16,92 @@ This method interactively authenticates an application through [`InteractiveBrow
16
16
17
17
Interactive browser authentication enables the application for all operations allowed by the interactive login credentials. As a result, if you're the owner or administrator of your subscription, your code has inherent access to most resources in that subscription without having to assign any specific permissions. For this reason, the use of interactive browser authentication is discouraged for anything but experimentation.
18
18
19
+
### Enable applications for interactive browser authentication
20
+
21
+
Perform the following steps to enable the application to authenticate through the interactive browser flow. These steps also work for the [device code authentication](#device-code-authentication) flow described later. This process is only necessary if you are using `InteractiveBrowserCredential` in your code.
22
+
23
+
1. In the [Azure portal](https://portal.azure.com), navigate to **Microsoft Entra ID** and select **App registrations** on the left navigation.
24
+
1. Select the registration for your app, then select **Authentication**.
25
+
1. Under **Advanced settings**, select **Yes** for **Allow public client flows**.
26
+
1. Select **Save** to apply the changes.
27
+
1. To authorize the application for specific resources, navigate to the resource in question, select **API Permissions**, and enable **Microsoft Graph** and other resources you want to access. Microsoft Graph is usually enabled by default.
28
+
29
+
> [!IMPORTANT]
30
+
> You must also be the admin of your tenant to grant consent to your application when you sign in for the first time.
31
+
19
32
### Example using InteractiveBrowserCredential
20
33
21
34
The following example demonstrates using an [`InteractiveBrowserCredential`](/dotnet/api/azure.identity.interactivebrowsercredential) to authenticate with the [`BlobServiceClient`](/dotnet/api/azure.storage.blobs.blobserviceclient):
For more exact control, such as setting redirect URIs, you can supply specific arguments to `InteractiveBrowserCredential` such as `redirect_uri`.
30
39
31
-
foreach (varblobIteminclient.GetBlobContainers())
32
-
{
33
-
Console.WriteLine(blobItem.Name);
34
-
}
35
-
```
40
+
## Interactive brokered authentication
36
41
37
-
For more exact control, such as setting redirect URIs, you can supply specific arguments to `InteractiveBrowserCredential` such as `redirect_uri`.
42
+
This method interactively authenticates an application through [`InteractiveBrowserCredential`](/dotnet/api/azure.identity.interactivebrowsercredential?view=azure-dotnet) by collecting user credentials using the system authentication broker. A system authentication broker is an app running on a user's machine that manages the authentication handshakes and token maintenance for all connected accounts. Currently, only the Windows authentication broker, Web Account Manager (WAM), is supported. Users on macOS and Linux will be authenticated through the non-brokered interactive browser flow.
43
+
44
+
WAM enables identity providers such as Microsoft Entra ID to natively plug into the OS and provide the service to other apps to provide a more secure login process. WAM offers the following benefits:
45
+
46
+
-**Feature support**: Apps can access OS-level and service-level capabilities, including Windows Hello, conditional access policies, and FIDO keys.
47
+
-**Streamlined single sign-on**: Apps can use the built-in account picker, allowing the user to select an existing account instead of repeatedly entering the same credentials.
48
+
-**Enhanced security**: Bug fixes and enhancements ship with Windows.
49
+
-**Token protection**: Refresh tokens are device-bound, and apps can acquire device-bound access tokens.
50
+
51
+
Interactive brokered authentication enables the application for all operations allowed by the interactive login credentials. Personal Microsoft accounts and work or school accounts are supported. If a supported version of Windows is used, the default browser-based UI is replaced with a smoother authentication experience, similar to Windows built-in apps.
52
+
53
+
### Enable applications for interactive brokered authentication
54
+
55
+
Perform the following steps to enable the application to authenticate through the interactive broker flow.
56
+
57
+
1. On the [Azure portal](https://portal.azure.com), navigate to **Microsoft Entra ID** and select **App registrations** on the left-hand menu.
58
+
1. Select the registration for your app, then select **Authentication**.
59
+
1. Add the WAM redirect URI to your app registration via a platform configuration:
60
+
1. Under **Platform configurations**, select **+ Add a platform**.
61
+
1. Under **Configure platforms**, select the tile for your application type (platform) to configure its settings, such as **mobile and desktop applications**.
62
+
1. In **Custom redirect URIs**, enter the following WAM redirect URI:
The `{client_id}` placeholder must be replaced with the **Application (client) ID** listed on the **Overview** pane of the app registration.
69
+
70
+
1. Select **Configure**.
71
+
72
+
To learn more, see [Add a redirect URI to an app registration](/entra/identity-platform/quickstart-register-app#add-a-redirect-uri).
73
+
74
+
1. Back on the **Authentication** pane, under **Advanced settings**, select **Yes** for **Allow public client flows**.
75
+
1. Select **Save** to apply the changes.
76
+
1. To authorize the application for specific resources, navigate to the resource in question, select **API Permissions**, and enable **Microsoft Graph** and other resources you want to access. Microsoft Graph is usually enabled by default.
77
+
78
+
> [!IMPORTANT]
79
+
> You must also be the admin of your tenant to grant consent to your application when you sign in for the first time.
80
+
81
+
### Example using InteractiveBrowserCredential
82
+
83
+
The following example demonstrates using an [`InteractiveBrowserCredential`](/dotnet/api/azure.identity.interactivebrowsercredential?view=azure-dotnet) in a Windows Forms app to authenticate with the [`BlobServiceClient`](/dotnet/api/azure.storage.blobs.blobserviceclient):
> Visit the [Parent window handles](/entra/msal/dotnet/acquiring-tokens/desktop-mobile/wam#parent-window-handles) and [Retrieve a window handle](/windows/apps/develop/ui-input/retrieve-hwnd) articles for more information about retrieving window handles.
89
+
90
+
For the code to run successfully, your user account must be assigned an Azure role on the storage account that allows access to blob containers such as **Storage Account Data Contributor**. If an app is specified, it must have API permissions set for **user_impersonation Access Azure Storage** (step 6 in the previous section). This API permission allows the app to access Azure storage on behalf of the signed-in user after consent is granted during sign-in.
91
+
92
+
The following screenshot shows the user sign-in experience:
93
+
94
+
:::image type="content" source="../media/web-account-manager-sign-in-account-picker.png" alt-text="A screenshot that shows the sign-in experience when using the interactive browser broker credential to authenticate a user." :::
95
+
96
+
### Authenticate the default system account via WAM
97
+
98
+
Many people always sign in to Windows with the same user account and, therefore, only ever want to authenticate using that account. WAM and `InteractiveBrowserCredential` also support a silent login process that automatically uses a default account so the user doesn't have to repeatedly select it.
99
+
100
+
The following example shows how to enable sign-in with the default system account:
Once you opt into this behavior, the credential attempts to sign in by asking the underlying Microsoft Authentication Library (MSAL) to perform the sign-in for the default system account. If the sign-in fails, the credential falls back to displaying the account picker dialog, from which the user can select the appropriate account.
38
105
39
106
## Device code authentication
40
107
@@ -49,7 +116,7 @@ For more information, see [Microsoft identity platform and the OAuth 2.0 device
49
116
50
117
Device code authentication in a development environment enables the application for all operations allowed by the interactive login credentials. As a result, if you're the owner or administrator of your subscription, your code has inherent access to most resources in that subscription without having to assign any specific permissions. However, you can use this method with a specific client ID, rather than the default, for which you can assign specific permissions.
51
118
52
-
## Authentication with a username and password
119
+
## Username and password authentication
53
120
54
121
This method authenticates an application using previously collected credentials and the [UsernamePasswordCredential](/dotnet/api/azure.identity.usernamepasswordcredential) object.
55
122
@@ -58,21 +125,4 @@ This method authenticates an application using previously collected credentials
58
125
>
59
126
> Furthermore, this method authenticates only work and school accounts; Microsoft accounts aren't supported. For more information, see [Sign up your organization to use Microsoft Entra ID](/entra/fundamentals/sign-up-organization).
0 commit comments