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
@@ -73,7 +73,7 @@ This project can be run in either Visual Studio or Visual Studio for Mac and can
73
73
1. In *appsettings.json*, replace the values of `Tenant`, `ClientId`, and `ClientSecret`. The value for the application (client) ID and the directory (tenant) ID, can be found in the app's **Overview** page on the Azure portal.
74
74
75
75
```json
76
-
"Tenant": "Enter_the_Tenant_Id_Here",
76
+
"TenantId": "Enter_the_Tenant_Id_Here",
77
77
"ClientId": "Enter_the_Application_Id_Here",
78
78
"ClientSecret": "Enter_the_Client_Secret_Here"
79
79
```
@@ -120,65 +120,94 @@ In that code:
120
120
121
121
-`{ProjectFolder}` is the folder where you extracted the .zip file. An example is `C:\Azure-Samples\active-directory-dotnetcore-daemon-v2`.
122
122
123
-
A list of users in Azure Active Directory should be displayed as a result.
123
+
The number of users in Azure Active Directory should be displayed as a result.
124
124
125
-
This quickstart application uses a client secret to identify itself as a confidential client. The client secret is added as a plain-text file to the project files. For security reasons, it is recommended to use a certificate instead of a client secret before considering the application as a production application. For more information on how to use a certificate, see [these instructions](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/#variation-daemon-application-using-client-credentials-with-certificates).
125
+
This quickstart application uses a client secret to identify itself as a confidential client. The client secret is added as a plain-text file to the project files. For security reasons, it's recommended to use a certificate instead of a client secret before considering the application as a production application. For more information on how to use a certificate, see [these instructions](https://github.com/Azure-Samples/active-directory-dotnetcore-daemon-v2/#variation-daemon-application-using-client-credentials-with-certificates).
126
126
127
127
## More information
128
128
129
129
This section provides an overview of the code required to sign in users. The overview can be useful to understand how the code works, what the main arguments are, and how to add sign-in to an existing .NET Core console application.
130
130
131
-
### MSAL.NET
131
+
### Microsoft.Identity.Web.MicrosoftGraph
132
132
133
-
Microsoft Authentication Library (MSAL, in the [Microsoft.Identity.Client](https://www.nuget.org/packages/Microsoft.Identity.Client) package) is the library that's used to sign in users and request tokens for accessing an API protected by the Microsoft identity platform. This quickstart requests tokens by using the application's own identity instead of delegated permissions. The authentication flow in this case is known as a [client credentials OAuth flow](../../v2-oauth2-client-creds-grant-flow.md). For more information on how to use MSAL.NET with a client credentials flow, see [this article](https://aka.ms/msal-net-client-credentials).
133
+
Microsoft Identity Web (in the [Microsoft.Identity.Web.TokenAcquisition](https://www.nuget.org/packages/Microsoft.Identity.Web.TokenAcquisition) package) is the library that's used to request tokens for accessing an API protected by the Microsoft identity platform. This quickstart requests tokens by using the application's own identity instead of delegated permissions. The authentication flow in this case is known as a [client credentials OAuth flow](../../v2-oauth2-client-creds-grant-flow.md). For more information on how to use MSAL.NET with a client credentials flow, see [this article](https://aka.ms/msal-net-client-credentials). Given the daemon app in this quickstart calls Microsoft Graph, you install the [Microsoft.Identity.Web.MicrosoftGraph](https://www.nuget.org/packages/Microsoft.Identity.Web.MicrosoftGraph) package, which handles automatically authenticated requests to Microsoft Graph (and references itself Microsoft.Identity.Web.TokenAcquisition)
134
134
135
-
MSAL.NET can be installed by running the following command in the Visual Studio Package Manager Console:
135
+
Microsoft.Identity.Web.MicrosoftGraph can be installed by running the following command in the Visual Studio Package Manager Console:
// For more token cache serialization options, see https://aka.ms/msal-net-token-cache-serialization
167
+
168
+
// Resolve the dependency injection.
169
+
varserviceProvider=tokenAcquirerFactory.Build();
170
+
```
171
+
172
+
This code uses the configuration defined in the appsettings.json file:
173
+
174
+
```json
175
+
{
176
+
"AzureAd": {
177
+
"Instance": "https://login.microsoftonline.com/",
178
+
"TenantId": "[Enter here the tenantID or domain name for your Azure AD tenant]",
179
+
"ClientId": "[Enter here the ClientId for your application]",
180
+
"ClientCredentials": [
181
+
{
182
+
"SourceType": "ClientSecret",
183
+
"ClientSecret": "[Enter here a client secret for your application]"
184
+
}
185
+
]
186
+
}
187
+
}
157
188
```
158
189
159
190
| Element | Description |
160
191
|---------|---------|
161
-
|`config.ClientSecret`| The client secret created for the application in the Azure portal. |
162
-
|`config.ClientId`| The application (client) ID for the application registered in the Azure portal. You can find this value on the app's **Overview** page in the Azure portal. |
163
-
|`config.Authority`| (Optional) The security token service (STS) endpoint for the user to authenticate. It's usually `https://login.microsoftonline.com/{tenant}` for the public cloud, where `{tenant}` is the name of your tenant or your tenant ID.|
192
+
|`ClientSecret`| The client secret created for the application in the Azure portal. |
193
+
|`ClientId`| The application (client) ID for the application registered in the Azure portal. This value can be found on the app's **Overview** page in the Azure portal. |
194
+
|`Instance`| (Optional) The security token service (STS) could instance endpoint for the app to authenticate. It's usually `https://login.microsoftonline.com/` for the public cloud.|
195
+
|`TenantId`| Name of the tenant or the tenant ID.|
164
196
165
-
For more information, see the [reference documentation for `ConfidentialClientApplication`](/dotnet/api/microsoft.identity.client.iconfidentialclientapplication).
197
+
For more information, see the [reference documentation for `ConfidentialClientApplication`](/dotnet/api/microsoft.identity.web.tokenacquirerfactory).
166
198
167
-
### Requesting tokens
199
+
### Calling Microsoft Graph
168
200
169
201
To request a token by using the app's identity, use the `AcquireTokenForClient` method:
|`scopes`| Contains the requested scopes. For confidential clients, this value should use a format similar to `{Application ID URI}/.default`. This format indicates that the requested scopes are the ones that are statically defined in the app object set in the Azure portal. For Microsoft Graph, `{Application ID URI}` points to `https://graph.microsoft.com`. For custom web APIs, `{Application ID URI}` is defined in the Azure portal, under **Application Registration (Preview)** > **Expose an API**. |
179
-
180
-
For more information, see the [reference documentation for `AcquireTokenForClient`](/dotnet/api/microsoft.identity.client.confidentialclientapplication.acquiretokenforclient).
181
-
182
211
[!INCLUDE [Help and support](../../../../../includes/active-directory-develop-help-support-include.md)]
> 
104
104
>
105
-
> ### MSAL.NET
105
+
> ### Microsoft.Identity.Web.MicrosoftGraph
106
106
>
107
-
> Microsoft Authentication Library (MSAL, in the [Microsoft.Identity.Client](https://www.nuget.org/packages/Microsoft.Identity.Client) package) is the library that's used to sign in users and request tokens for accessing an API protected by the Microsoft identity platform. This quickstart requests tokens by using the application's own identity instead of delegated permissions. The authentication flow in this case is known as a [client credentials OAuth flow](v2-oauth2-client-creds-grant-flow.md). For more information on how to use MSAL.NET with a client credentials flow, see [this article](https://aka.ms/msal-net-client-credentials).
107
+
> Microsoft Identity Web (in the [Microsoft.Identity.Web.TokenAcquisition](https://www.nuget.org/packages/Microsoft.Identity.Web.TokenAcquisition) package) is the library that's used to request tokens for accessing an API protected by the Microsoft identity platform. This quickstart requests tokens by using the application's own identity instead of delegated permissions. The authentication flow in this case is known as a [client credentials OAuth flow](v2-oauth2-client-creds-grant-flow.md). For more information on how to use MSAL.NET with a client credentials flow, see [this article](https://aka.ms/msal-net-client-credentials). Given the daemon app in this quickstart calls Microsoft Graph, you install tje [Microsoft.Identity.Web.MicrosoftGraph](https://www.nuget.org/packages/Microsoft.Identity.Web.MicrosoftGraph) package, which handles automatically authenticated requests to Microsoft Graph (and references itself Microsoft.Identity.Web.TokenAcquisition)
108
108
>
109
-
> MSAL.NET can be installed by running the following command in the Visual Studio Package Manager Console:
109
+
> Microsoft.Identity.Web.MicrosoftGraph can be installed by running the following command in the Visual Studio Package Manager Console:
> "TenantId": "[Enter here the tenantID or domain name for your Azure AD tenant]",
153
+
> "ClientId": "[Enter here the ClientId for your application]",
154
+
> "ClientCredentials": [
155
+
> {
156
+
> "SourceType": "ClientSecret",
157
+
> "ClientSecret": "[Enter here a client secret for your application]"
158
+
> }
159
+
> ]
160
+
> }
161
+
> }
131
162
> ```
132
163
>
133
164
> | Element | Description |
134
165
> |---------|---------|
135
-
> | `config.ClientSecret` | The client secret created for the application in the Azure portal. |
136
-
> | `config.ClientId` | The application (client) ID for the application registered in the Azure portal. This value can be found on the app's **Overview** page in the Azure portal. |
137
-
> | `config.Authority` | (Optional) The security token service (STS) endpoint for the user to authenticate. It's usually `https://login.microsoftonline.com/{tenant}` for the public cloud, where `{tenant}` is the name of the tenant or the tenant ID.|
166
+
> | `ClientSecret` | The client secret created for the application in the Azure portal. |
167
+
> | `ClientId` | The application (client) ID for the application registered in the Azure portal. This value can be found on the app's **Overview** page in the Azure portal. |
168
+
> | `Instance` | (Optional) The security token service (STS) could instance endpoint for the app to authenticate. It's usually `https://login.microsoftonline.com/` for the public cloud.|
169
+
> | `TenantId` | Name of the tenant or the tenant ID.|
138
170
>
139
-
> For more information, see the [reference documentation for `ConfidentialClientApplication`](/dotnet/api/microsoft.identity.client.iconfidentialclientapplication).
171
+
> For more information, see the [reference documentation for `ConfidentialClientApplication`](/dotnet/api/microsoft.identity.web.tokenacquirerfactory).
140
172
>
141
-
> ### Requesting tokens
173
+
> ### Calling Microsoft Graph
142
174
>
143
175
> To request a token by using the app's identity, use the `AcquireTokenForClient` method:
144
176
>
145
177
> ```csharp
146
-
> result = await app.AcquireTokenForClient(scopes)
> | `scopes` | Contains the requested scopes. For confidential clients, this value should use a format similar to `{Application ID URI}/.default`. This format indicates that the requested scopes are the ones that are statically defined in the app object set in the Azure portal. For Microsoft Graph, `{Application ID URI}` points to `https://graph.microsoft.com`. For custom web APIs, `{Application ID URI}` is defined in the Azure portal, under **Application Registration (Preview)** > **Expose an API**. |
153
-
>
154
-
> For more information, see the [reference documentation for `AcquireTokenForClient`](/dotnet/api/microsoft.identity.client.confidentialclientapplication.acquiretokenforclient).
155
-
>
156
185
> [!INCLUDE [Help and support](../../../includes/active-directory-develop-help-support-include.md)]
0 commit comments