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: aspnetcore/security/authentication/social/facebook-logins.md
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -134,9 +134,7 @@ We recommend the `AccessDeniedPath` page contains the following information:
134
134
<!-- End of React -->
135
135
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]
136
136
137
-
[!INCLUDE[](includes/chain-auth-providers.md)]
138
-
139
-
For more information on configuration options supported by Facebook authentication, see the <xref:Microsoft.AspNetCore.Builder.FacebookOptions> API reference. Configuration options can be used to:
137
+
For more information on configuration options supported by Facebook authentication, see the <xref:Microsoft.AspNetCore.Builder.FacebookOptions> API reference. Configuration options can be used to:
140
138
141
139
* Request different information about the user.
142
140
* Add query string arguments to customize the login experience.
@@ -153,3 +151,7 @@ We recommend the `AccessDeniedPath` page contains the following information:
153
151
* Once you publish your web site to Azure web app, you should reset the `AppSecret` in the Facebook developer portal.
154
152
155
153
* Set the `Authentication:Facebook:AppId` and `Authentication:Facebook:AppSecret` as application settings in the Azure portal. The configuration system is set up to read keys from environment variables.
Copy file name to clipboardExpand all lines: aspnetcore/security/authentication/social/google-logins.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -117,3 +117,7 @@ The user is now logged in using Google credentials.
117
117
* This article demonstrates authentication with Google. For information on authenticating with other external providers, see <xref:security/authentication/social/index>.
118
118
* After the app is deployed to Azure, reset the `ClientSecret` in the Google API console.
119
119
* Set the `Authentication:Google:ClientId` and `Authentication:Google:ClientSecret` as app settings in the Azure portal. The configuration system is set up to read keys from the environment variables.
Copy file name to clipboardExpand all lines: aspnetcore/security/authentication/social/index.md
+48-25Lines changed: 48 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -4,21 +4,18 @@ author: rick-anderson
4
4
description: Create an ASP.NET Core app using Identity with external authentication providers such as Facebook, Twitter, Google, and Microsoft.
5
5
ms.author: riande
6
6
ms.custom: mvc
7
-
ms.date: 03/07/2022
7
+
ms.date: 07/09/2025
8
8
uid: security/authentication/social/index
9
9
---
10
10
# External provider authentication in ASP.NET Core Identity
11
11
12
12
By [Valeriy Novytskyy](https://github.com/01binary) and [Rick Anderson](https://twitter.com/RickAndMSFT)
13
13
14
-
This tutorial demonstrates how to build an ASP.NET Core app that enables users to sign in using OAuth 2.0 with credentials from external authentication providers.
14
+
This article explains how to build an ASP.NET Core app that enables users to sign in using OAuth 2.0 with credentials from external authentication providers.
15
15
16
16
[Facebook](xref:security/authentication/facebook-logins), [Twitter](xref:security/authentication/twitter-logins), [Google](xref:security/authentication/google-logins), and [Microsoft](xref:security/authentication/microsoft-logins) providers are covered in the following sections and use the starter project created in this article. Other providers are available in third-party packages such as [OpenIddict](https://documentation.openiddict.com/integrations/web-providers), [AspNet.Security.OAuth.Providers](https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers) and [AspNet.Security.OpenId.Providers](https://github.com/aspnet-contrib/AspNet.Security.OpenId.Providers).
17
17
18
-
Enabling users to sign in with their existing credentials:
19
-
20
-
* Is convenient for the users.
21
-
* Shifts many of the complexities of managing the sign-in process onto a third party.
18
+
Enabling users to sign in with their existing credentials is convenient for the users and shifts many of the complexities of managing the sign-in process onto a third party.
22
19
23
20
## Create a New ASP.NET Core Project
24
21
@@ -27,11 +24,11 @@ Enabling users to sign in with their existing credentials:
27
24
* Select the **ASP.NET Core Web App** template. Select **OK**.
28
25
* In the **Authentication type** input, select **Individual Accounts**.
29
26
30
-
# [Visual Studio Code](#tab/visual-studio-code)
27
+
# [Visual Studio Code / .NET CLI](#tab/visual-studio-code+net-cli)
31
28
32
-
* Open the terminal. For Visual Studio Code you can open the [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal).
29
+
* Open a command shell. For Visual Studio Code, you can use the [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal).
33
30
34
-
* Change directories (`cd`) to a folder which will contain the project.
31
+
* Change directories (`cd`) to a folder for the sample app.
35
32
36
33
* For Windows, run the following command:
37
34
@@ -45,10 +42,12 @@ Enabling users to sign in with their existing credentials:
45
42
dotnet new webapp -o WebApp1 -au Individual
46
43
```
47
44
48
-
* The `dotnet new` command creates a new Razor Pages project in the *WebApp1* folder.
45
+
* The `dotnet new` command uses the `-o|--output` option to create a new Razor Pages project in the `WebApp1` folder.
49
46
*`-au Individual` creates the code for Individual authentication.
50
47
*`-uld` uses LocalDB, a lightweight version of SQL Server Express for Windows. Omit `-uld` to use SQLite.
51
48
49
+
For more information, see [`dotnet new <TEMPLATE>`](/dotnet/core/tools/dotnet-new).
50
+
52
51
---
53
52
54
53
## Apply migrations
@@ -59,45 +58,69 @@ Enabling users to sign in with their existing credentials:
59
58
60
59
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]
61
60
62
-
## Use SecretManager to store tokens assigned by login providers
61
+
## Use Secret Manager to store tokens assigned by login providers
63
62
64
-
Social login providers assign **Application Id** and **Application Secret** tokens during the registration process. The exact token names vary by provider. These tokens represent the credentials your app uses to access their API. The tokens constitute the "user secrets" that can be linked to your app configuration with the help of [Secret Manager](xref:security/app-secrets#secret-manager). User secrets are a more secure alternative to storing the tokens in a configuration file, such as `appsettings.json`.
63
+
Social login providers assign **Application Id** and **Application Secret** tokens during the registration process. The exact token names vary by provider. These tokens represent the credentials that the app uses to access the provider's API. The tokens constitute *user secrets* that can be linked to your app configuration with the help of [Secret Manager](xref:security/app-secrets#secret-manager). User secrets are a more secure alternative to storing the tokens in a configuration file, such as `appsettings.json`.
65
64
66
65
> [!IMPORTANT]
67
-
> Secret Manager is for development purposes only. You can store and protect Azure test and production secrets with the [Azure Key Vault configuration provider](xref:security/key-vault-configuration).
66
+
> Secret Manager is only for local development and testing. Protect staging and production secrets with the [Azure Key Vault configuration provider](xref:security/key-vault-configuration), which can also be used for local development and testing if you prefer not to use the Secret Manager locally.
68
67
69
-
Follow the steps in [Safe storage of app secrets in development in ASP.NET Core](xref:security/app-secrets) topic to store tokens assigned by each login provider below.
68
+
For guidance on storing the tokens assigned by each login provider, see <xref:security/app-secrets>.
70
69
71
-
## Setup login providers required by your application
70
+
## Configure login providers
72
71
73
-
Use the following topics to configure your application to use the respective providers:
72
+
Use the following articles to configure login providers and the app:
When the app requires multiple providers, chain the provider extension methods on <xref:Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions.AddAuthentication%2A>:
83
+
84
+
```csharp
85
+
builder.Services.AddAuthentication()
86
+
.AddGoogle(options=>
87
+
{
88
+
// Google configuration options
89
+
})
90
+
.AddFacebook(options=>
91
+
{
92
+
// Facebook configuration options
93
+
})
94
+
.AddMicrosoftAccount(options=>
95
+
{
96
+
// Microsoft Account configuration options
97
+
})
98
+
.AddTwitter(options=>
99
+
{
100
+
// Twitter configuration options
101
+
});
102
+
```
103
+
104
+
For detailed configuration guidance on each provider, see their respective articles.
82
105
83
-
## Optionally set password
106
+
## Optionally set a password
84
107
85
-
When you register with an external login provider, you don't have a password registered with the app. This alleviates you from creating and remembering a password for the site, but it also makes you dependent on the external login provider. If the external login provider is unavailable, you won't be able to sign in to the web site.
108
+
When you register with an external login provider, you don't have a password registered with the app. This alleviates you from creating and remembering a password for the site, but it also makes you completely dependent on the external login provider for site access. If the external login provider is unavailable, you won't be able to sign in to the app.
86
109
87
-
To create a password and sign in using your email that you set during the signin process with external providers:
110
+
To create a password and sign in using your email that you set during the sign-in process with external providers:
88
111
89
-
* Select the **Hello <email alias>** link at the top-right corner to navigate to the **Manage** view.
112
+
* Select the **Hello <email alias>** link at the top-right corner to navigate to the **Manage** view:

96
119
97
-
* Set a valid password and you can use this to sign in with your email.
120
+
* Set a valid password, and you can use this credential to sign in with your email address.
98
121
99
122
## Additional information
100
123
101
124
*[Sign in with Apple Example Integration](https://github.com/martincostello/SignInWithAppleSample)
102
-
*See [this GitHub issue](https://github.com/dotnet/AspNetCore.Docs/issues/10563) for information on how to customize the login buttons.
103
-
* Persist additional data about the user and their access and refresh tokens. For more information, see <xref:security/authentication/social/additional-claims>.
125
+
*[How to customize the login buttons (`dotnet/AspNetCore.Docs`#10563)](https://github.com/dotnet/AspNetCore.Docs/issues/10563)
126
+
*[Persist additional data about the user and their access and refresh tokens](xref:security/authentication/social/additional-claims)
Copy file name to clipboardExpand all lines: aspnetcore/security/authentication/social/microsoft-logins.md
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ For more information about configuration options supported by Microsoft Account
57
57
58
58
You're now logged in using your Microsoft credentials.
59
59
60
-
[!INCLUDE[](includes/chain-auth-providers.md)]
60
+
To use multiple authentication providers, see <xref:security/authentication/social/index#multiple-authentication-providers>.
61
61
62
62
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]
63
63
@@ -124,8 +124,6 @@ Tap **Yes** and you'll be redirected back to the web site where you can set your
124
124
125
125
You're now logged in using your Microsoft credentials.
126
126
127
-
[!INCLUDE[](includes/chain-auth-providers.md)]
128
-
129
127
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]
130
128
131
129
## Troubleshooting
@@ -143,3 +141,7 @@ You're now logged in using your Microsoft credentials.
143
141
* Set the `Authentication:Microsoft:ClientId` and `Authentication:Microsoft:ClientSecret` as application settings in Microsoft Entra admin center. The configuration system is set up to read keys from environment variables.
For more information on configuration options supported by Twitter authentication, see the <xref:Microsoft.AspNetCore.Builder.TwitterOptions> API reference. This can be used to request different information about the user.
81
78
82
79
## Sign in with Twitter
@@ -109,3 +106,7 @@ Rather in the twitter setup, you can provide an External sign-in homepage. The e
109
106
* Once you publish your web site to Azure web app, you should reset the `ConsumerSecret` in the Twitter developer portal.
110
107
111
108
* Set the `Authentication:Twitter:ConsumerKey` and `Authentication:Twitter:ConsumerSecret` as application settings in the Azure portal. The configuration system is set up to read keys from environment variables.
0 commit comments