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
@@ -28,11 +28,11 @@ The following Microsoft libraries support daemon apps:
28
28
29
29
## Configure the authority
30
30
31
-
Daemon applications use application permissions rather than delegated permissions. So their supported account type can't be an account in any organizational directory or any personal Microsoft account (for example, Skype, Xbox, Outlook.com). There's no tenant admin to grant consent to a daemon application for a Microsoft personal account. You'll need to choose *accounts in my organization* or *accounts in any organization*.
31
+
Daemon applications use application permissions rather than delegated permissions. So their supported account type can't be an account in any organizational directory or any personal Microsoft account (for example, Skype, Xbox, Outlook.com). There's no tenant admin to grant consent to a daemon application for a Microsoft personal account. You need to choose *accounts in my organization* or *accounts in any organization*.
32
32
33
33
The authority specified in the application configuration should be tenanted (specifying a tenant ID or a domain name associated with your organization).
34
34
35
-
Even if you want to provide a multitenant tool, you should use a tenant ID or domain name, and **not**`common` or `organizations` with this flow, because the service cannot reliably infer which tenant should be used.
35
+
Even if you want to provide a multitenant tool, you should use a tenant ID or domain name, and **not**`common` or `organizations` with this flow, because the service can't reliably infer which tenant should be used.
36
36
37
37
## Configure and instantiate the application
38
38
@@ -49,21 +49,28 @@ The configuration file defines:
49
49
- The client ID that you got from the application registration.
50
50
- Either a client secret or a certificate.
51
51
52
-
# [.NET](#tab/dotnet)
52
+
# [.NET](#tab/idweb)
53
53
54
-
Here's an example of defining the configuration in an [*appsettings.json*](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/blob/master/1-Call-MSGraph/daemon-console/appsettings.json) file. This example is taken from from the [.NET Core console daemon](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2) code sample on GitHub.
54
+
Here's an example of defining the configuration in an [*appsettings.json*](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/blob/master/1-Call-MSGraph/daemon-console/appsettings.json) file. This example is taken from the [.NET Core console daemon](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2) code sample on GitHub.
"Tenant": "[Enter here the tenantID or domain name for your Azure AD tenant]",
60
-
"ClientId": "[Enter here the ClientId for your application]",
61
-
"ClientSecret": "[Enter here a client secret for your application]",
62
-
"CertificateName": "[Or instead of client secret: Enter here the name of a certificate (from the user cert store) as registered with your application]"
58
+
"AzureAd": {
59
+
"Instance": "https://login.microsoftonline.com/",
60
+
"TenantId": "[Enter here the tenantID or domain name for your Azure AD tenant]",
61
+
"ClientId": "[Enter here the ClientId for your application]",
62
+
"ClientCredentials": [
63
+
{
64
+
"SourceType": "ClientSecret",
65
+
"ClientSecret": "[Enter here a client secret for your application]"
66
+
}
67
+
]
68
+
}
63
69
}
70
+
64
71
```
65
72
66
-
You provide either a `ClientSecret` or a `CertificateName`. These settings are exclusive.
73
+
You provide a certificate instead of the client secret, or [workload identity federation](/azure/active-directory/workload-identities/workload-identity-federation.md) credentials.
67
74
68
75
# [Java](#tab/java)
69
76
@@ -123,6 +130,22 @@ When you build a confidential client with certificates, the [parameters.json](ht
123
130
}
124
131
```
125
132
133
+
# [.NET (low level) ](#tab/dotnet)
134
+
135
+
Here's an example of defining the configuration in an [*appsettings.json*](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/blob/master/1-Call-MSGraph/daemon-console/appsettings.json) file. This example is taken from the [.NET Core console daemon](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2) code sample on GitHub.
"Tenant": "[Enter here the tenantID or domain name for your Azure AD tenant]",
141
+
"ClientId": "[Enter here the ClientId for your application]",
142
+
"ClientSecret": "[Enter here a client secret for your application]",
143
+
"CertificateName": "[Or instead of client secret: Enter here the name of a certificate (from the user cert store) as registered with your application]"
144
+
}
145
+
```
146
+
147
+
You provide either a `ClientSecret` or a `CertificateName`. These settings are exclusive.
148
+
126
149
---
127
150
128
151
### Instantiate the MSAL application
@@ -135,15 +158,38 @@ The construction is different, depending on whether you're using client secrets
135
158
136
159
Reference the MSAL package in your application code.
137
160
138
-
# [.NET](#tab/dotnet)
161
+
# [.NET](#tab/idweb)
139
162
140
-
Add the [Microsoft.Identity.Client](https://www.nuget.org/packages/Microsoft.Identity.Client) NuGet package to your application, and then add a `using` directive in your code to reference it.
163
+
Add the [Microsoft.Identity.Web.TokenAcquisition](https://www.nuget.org/packages/Microsoft.Identity.Web.TokenAcquisition) NuGet package to your application.
164
+
Alternatively, if you want to call Microsoft Graph, add the [Microsoft.Identity.Web.MicrosoftGraph](https://www.nuget.org/packages/Microsoft.Identity.Web.MicrosoftGraph) package.
165
+
Your project could be as follows. The *appsettings.json* file needs to be copied to the output directory.
141
166
142
-
In MSAL.NET, the confidential client application is represented by the `IConfidentialClientApplication` interface.
Simply install the packages by running `npm install` in the folder where *package.json* file resides. Then, import **msal-node** package:
209
+
Install the packages by running `npm install` in the folder where *package.json* file resides. Then, import **msal-node** package:
164
210
165
211
```JavaScript
166
212
constmsal=require('@azure/msal-node');
@@ -175,38 +221,52 @@ import sys
175
221
import logging
176
222
```
177
223
178
-
---
224
+
# [.NET (low level)](#tab/dotnet)
179
225
180
-
#### Instantiate the confidential client application with a client secret
181
-
182
-
Here's the code to instantiate the confidential client application with a client secret:
226
+
Add the [Microsoft.Identity.Client](https://www.nuget.org/packages/Microsoft.Identity.Client) NuGet package to your application, and then add a `using` directive in your code to reference it.
183
227
184
-
# [.NET](#tab/dotnet)
228
+
In MSAL.NET, the confidential client application is represented by the `IConfidentialClientApplication` interface.
The `Authority` is a concatenation of the cloud instance and the tenant ID, for example `https://login.microsoftonline.com/contoso.onmicrosoft.com` or `https://login.microsoftonline.com/eb1ed152-0000-0000-0000-32401f3f9abd`. In the *appsettings.json* file shown in the [Configuration file](#configuration-file) section, these are represented by the `Instance` and `Tenant` values, respectively.
235
+
---
194
236
195
-
In the code sample the previous snippet was taken from, `Authority` is a property on the [AuthenticationConfig](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/blob/ffc4a9f5d9bdba5303e98a1af34232b434075ac7/1-Call-MSGraph/daemon-console/AuthenticationConfig.cs#L61-L70) class, and is defined as such:
237
+
#### Instantiate the confidential client application with a client secret
238
+
239
+
Here's the code to instantiate the confidential client application with a client secret:
The `Authority` is a concatenation of the cloud instance and the tenant ID, for example `https://login.microsoftonline.com/contoso.onmicrosoft.com` or `https://login.microsoftonline.com/eb1ed152-0000-0000-0000-32401f3f9abd`. In the *appsettings.json* file shown in the [Configuration file](#configuration-file) section, instance and tenant are represented by the `Instance` and `Tenant` values, respectively.
331
+
332
+
In the code sample the previous snippet was taken from, `Authority` is a property on the [AuthenticationConfig](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/blob/ffc4a9f5d9bdba5303e98a1af34232b434075ac7/1-Call-MSGraph/daemon-console/AuthenticationConfig.cs#L61-L70) class, and is defined as such:
The code itself is exactly the same. The certificate is described in the configuration.
356
+
There are many ways to get the certificate. For details see https://aka.ms/ms-id-web-certificates.
357
+
Here's how you would do to get your certificate from KeyVault. Microsoft identity delegates to Azure Identity's DefaultAzureCredential, and used Managed identity when available to access the certificate from KeyVault. You can debug your application locally as it, then, uses your developer credentials.
When you use `WithClientClaims`, MSAL.NET will produce a signed assertion that contains the claims expected by Azure AD, plus additional client claims that you want to send.
For details, see the MSAL Python reference documentation for [ConfidentialClientApplication](https://msal-python.readthedocs.io/en/latest/#msal.ClientApplication.__init__).
431
504
505
+
# [.NET (low level)](#tab/dotnet)
506
+
507
+
Instead of a client secret or a certificate, the confidential client application can also prove its identity by using client assertions.
508
+
509
+
MSAL.NET has two methods to provide signed assertions to the confidential client app:
510
+
511
+
-`.WithClientAssertion()`
512
+
-`.WithClientClaims()`
513
+
514
+
When you use `WithClientAssertion`, provide a signed JWT. This advanced scenario is detailed in [Client assertions](msal-net-client-assertions.md).
When you use `WithClientClaims`, MSAL.NET produces a signed assertion that contains the claims expected by Azure AD, plus additional client claims that you want to send.
0 commit comments