Skip to content

Commit 02faa53

Browse files
authored
Social auth overview updates (#35732)
1 parent 7bcff9a commit 02faa53

File tree

9 files changed

+67
-120
lines changed

9 files changed

+67
-120
lines changed

aspnetcore/security/authentication/social/facebook-logins.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ We recommend the `AccessDeniedPath` page contains the following information:
134134
<!-- End of React -->
135135
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]
136136

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:
140138

141139
* Request different information about the user.
142140
* Add query string arguments to customize the login experience.
@@ -153,3 +151,7 @@ We recommend the `AccessDeniedPath` page contains the following information:
153151
* Once you publish your web site to Azure web app, you should reset the `AppSecret` in the Facebook developer portal.
154152

155153
* 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.
154+
155+
## Additional resources
156+
157+
[Multiple authentication providers](xref:security/authentication/social/index#multiple-authentication-providers)

aspnetcore/security/authentication/social/google-logins.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,7 @@ The user is now logged in using Google credentials.
117117
* This article demonstrates authentication with Google. For information on authenticating with other external providers, see <xref:security/authentication/social/index>.
118118
* After the app is deployed to Azure, reset the `ClientSecret` in the Google API console.
119119
* 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.
120+
121+
## Additional resources
122+
123+
[Multiple authentication providers](xref:security/authentication/social/index#multiple-authentication-providers)

aspnetcore/security/authentication/social/includes/chain-auth-providers.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

aspnetcore/security/authentication/social/includes/chain-auth-providers6.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

aspnetcore/security/authentication/social/index.md

Lines changed: 48 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@ author: rick-anderson
44
description: Create an ASP.NET Core app using Identity with external authentication providers such as Facebook, Twitter, Google, and Microsoft.
55
ms.author: riande
66
ms.custom: mvc
7-
ms.date: 03/07/2022
7+
ms.date: 07/09/2025
88
uid: security/authentication/social/index
99
---
1010
# External provider authentication in ASP.NET Core Identity
1111

1212
By [Valeriy Novytskyy](https://github.com/01binary) and [Rick Anderson](https://twitter.com/RickAndMSFT)
1313

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.
1515

1616
[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).
1717

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.
2219

2320
## Create a New ASP.NET Core Project
2421

@@ -27,11 +24,11 @@ Enabling users to sign in with their existing credentials:
2724
* Select the **ASP.NET Core Web App** template. Select **OK**.
2825
* In the **Authentication type** input, select **Individual Accounts**.
2926

30-
# [Visual Studio Code](#tab/visual-studio-code)
27+
# [Visual Studio Code / .NET CLI](#tab/visual-studio-code+net-cli)
3128

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).
3330

34-
* Change directories (`cd`) to a folder which will contain the project.
31+
* Change directories (`cd`) to a folder for the sample app.
3532

3633
* For Windows, run the following command:
3734

@@ -45,10 +42,12 @@ Enabling users to sign in with their existing credentials:
4542
dotnet new webapp -o WebApp1 -au Individual
4643
```
4744

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.
4946
* `-au Individual` creates the code for Individual authentication.
5047
* `-uld` uses LocalDB, a lightweight version of SQL Server Express for Windows. Omit `-uld` to use SQLite.
5148

49+
For more information, see [`dotnet new <TEMPLATE>`](/dotnet/core/tools/dotnet-new).
50+
5251
---
5352

5453
## Apply migrations
@@ -59,45 +58,69 @@ Enabling users to sign in with their existing credentials:
5958

6059
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]
6160

62-
## Use SecretManager to store tokens assigned by login providers
61+
## Use Secret Manager to store tokens assigned by login providers
6362

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`.
6564

6665
> [!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.
6867
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>.
7069

71-
## Setup login providers required by your application
70+
## Configure login providers
7271

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:
7473

7574
* [Facebook](xref:security/authentication/facebook-logins) instructions
7675
* [Twitter](xref:security/authentication/twitter-logins) instructions
7776
* [Google](xref:security/authentication/google-logins) instructions
7877
* [Microsoft](xref:security/authentication/microsoft-logins) instructions
7978
* [Other provider](xref:security/authentication/otherlogins) instructions
8079

81-
[!INCLUDE[](includes/chain-auth-providers6.md)]
80+
## Multiple authentication providers
81+
82+
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.
82105

83-
## Optionally set password
106+
## Optionally set a password
84107

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.
86109

87-
To create a password and sign in using your email that you set during the sign in 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:
88111

89-
* Select the **Hello &lt;email alias&gt;** link at the top-right corner to navigate to the **Manage** view.
112+
* Select the **Hello &lt;email alias&gt;** link at the top-right corner to navigate to the **Manage** view:
90113

91114
![Web application Manage view](index/_static/pass1a.png)
92115

93-
* Select **Create**
116+
* Select **Create**:
94117

95118
![Set your password page](index/_static/pass2a.png)
96119

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.
98121

99122
## Additional information
100123

101124
* [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)

aspnetcore/security/authentication/social/index/Program.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

aspnetcore/security/authentication/social/microsoft-logins.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ For more information about configuration options supported by Microsoft Account
5757
5858
You're now logged in using your Microsoft credentials.
5959
60-
[!INCLUDE[](includes/chain-auth-providers.md)]
60+
To use multiple authentication providers, see <xref:security/authentication/social/index#multiple-authentication-providers>.
6161
6262
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]
6363
@@ -124,8 +124,6 @@ Tap **Yes** and you'll be redirected back to the web site where you can set your
124124
125125
You're now logged in using your Microsoft credentials.
126126
127-
[!INCLUDE[](includes/chain-auth-providers.md)]
128-
129127
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]
130128
131129
## Troubleshooting
@@ -143,3 +141,7 @@ You're now logged in using your Microsoft credentials.
143141
* 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.
144142
145143
:::moniker-end
144+
145+
## Additional resources
146+
147+
[Multiple authentication providers](xref:security/authentication/social/index#multiple-authentication-providers)

aspnetcore/security/authentication/social/other-logins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ The following list includes common external OAuth authentication providers that
4444

4545
* [VK](https://vk.com/apps?act=manage) ([Instructions](https://vk.com/pages?oid=-17680044&p=Authorizing_Sites))
4646

47-
[!INCLUDE[Multiple authentication providers](includes/chain-auth-providers.md)]
47+
To use multiple authentication providers, see <xref:security/authentication/social/index#multiple-authentication-providers>.
4848

4949
[!INCLUDE[Forward request information when behind a proxy or load balancer section](includes/forwarded-headers-middleware.md)]

aspnetcore/security/authentication/social/twitter-logins.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,8 @@ Add the Authentication service to the `Startup.ConfigureServices`:
7272
7373
:::moniker-end
7474
75-
7675
[!INCLUDE [default settings configuration](includes/default-settings.md)]
7776
78-
[!INCLUDE[](includes/chain-auth-providers.md)]
79-
8077
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.
8178
8279
## Sign in with Twitter
@@ -109,3 +106,7 @@ Rather in the twitter setup, you can provide an External sign-in homepage. The e
109106
* Once you publish your web site to Azure web app, you should reset the `ConsumerSecret` in the Twitter developer portal.
110107
111108
* 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.
109+
110+
## Additional resources
111+
112+
[Multiple authentication providers](xref:security/authentication/social/index#multiple-authentication-providers)

0 commit comments

Comments
 (0)