#1004 clean up social sample code

This commit is contained in:
Chris R 2016-10-13 20:14:15 -07:00
parent 3eab3ef013
commit b1b5a40ebf
3 changed files with 22 additions and 26 deletions

View File

@ -29,7 +29,7 @@ namespace SocialSample
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json");
.AddJsonFile("appsettings.json", optional: true);
if (env.IsDevelopment())
{
@ -77,7 +77,14 @@ namespace SocialSample
LoginPath = new PathString("/login")
});
// You must first create an app with facebook and add it's ID and Secret to your config.json or user-secrets.
if (string.IsNullOrEmpty(Configuration["facebook:appid"]))
{
// User-Secrets: https://docs.asp.net/en/latest/security/app-secrets.html
// See below for registration instructions for each provider.
throw new InvalidOperationException("User secrets must be configured for each authentication provider.");
}
// You must first create an app with Facebook and add its ID and Secret to your user-secrets.
// https://developers.facebook.com/apps/
app.UseFacebookAuthentication(new FacebookOptions
{
@ -88,7 +95,8 @@ namespace SocialSample
SaveTokens = true,
});
// See config.json
// You must first create an app with Google and add its ID and Secret to your user-secrets.
// https://console.developers.google.com/project
app.UseOAuthAuthentication(new OAuthOptions
{
AuthenticationScheme = "Google-AccessToken",
@ -102,7 +110,7 @@ namespace SocialSample
SaveTokens = true
});
// See config.json
// You must first create an app with GitHub and add its ID and Secret to your user-secrets.
// https://console.developers.google.com/project
app.UseGoogleAuthentication(new GoogleOptions
{
@ -120,7 +128,7 @@ namespace SocialSample
}
});
// See config.json
// You must first create an app with Twitter and add its key and Secret to your user-secrets.
// https://apps.twitter.com/
app.UseTwitterAuthentication(new TwitterOptions
{
@ -151,14 +159,14 @@ namespace SocialSample
Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL:
https://localhost:44318/
*/
// See config.json
// You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets.
// https://apps.dev.microsoft.com/
app.UseOAuthAuthentication(new OAuthOptions
{
AuthenticationScheme = "Microsoft-AccessToken",
DisplayName = "MicrosoftAccount-AccessToken",
ClientId = Configuration["msa:clientid"],
ClientSecret = Configuration["msa:clientsecret"],
ClientId = Configuration["microsoftaccount:clientid"],
ClientSecret = Configuration["microsoftaccount:clientsecret"],
CallbackPath = new PathString("/signin-microsoft-token"),
AuthorizationEndpoint = MicrosoftAccountDefaults.AuthorizationEndpoint,
TokenEndpoint = MicrosoftAccountDefaults.TokenEndpoint,
@ -166,17 +174,17 @@ namespace SocialSample
SaveTokens = true
});
// See config.json
// You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets.
// https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/
app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions
{
DisplayName = "MicrosoftAccount",
ClientId = Configuration["msa:clientid"],
ClientSecret = Configuration["msa:clientsecret"],
ClientId = Configuration["microsoftaccount:clientid"],
ClientSecret = Configuration["microsoftaccount:clientsecret"],
SaveTokens = true
});
// See config.json
// You must first create an app with GitHub and add its ID and Secret to your user-secrets.
// https://github.com/settings/applications/
app.UseOAuthAuthentication(new OAuthOptions
{
@ -190,7 +198,8 @@ namespace SocialSample
SaveTokens = true
});
// See config.json
// You must first create an app with GitHub and add its ID and Secret to your user-secrets.
// https://github.com/settings/applications/
app.UseOAuthAuthentication(new OAuthOptions
{
AuthenticationScheme = "GitHub",

View File

@ -1,12 +0,0 @@
{
"google:clientid": "560027070069-37ldt4kfuohhu3m495hk2j4pjp92d382.apps.googleusercontent.com",
"google:clientsecret": "n2Q-GEw9RQjzcRbU3qhfTj8f",
"twitter:consumerkey": "VvNJRyGeqYBByN694UHudI2cv",
"twitter:consumersecret": "V2xEqWgmphPdlUXX4ARWsozl9lfbvr5wbAYw2LN8m6kZV7pt20",
"github:clientid": "49e302895d8b09ea5656",
"github:clientsecret": "98f1bf028608901e9df91d64ee61536fe562064b",
"github-token:clientid": "8c0c5a572abe8fe89588",
"github-token:clientsecret": "e1d95eaf03461d27acd6f49d4fc7bf19d6ac8cda",
"msa:clientid": "e2105565-1f56-434a-ae61-9849ebaf606c",
"msa:clientsecret": "pjqtt3RXrFwcfSJyQ0BeUez"
}

View File

@ -31,7 +31,6 @@
"userSecretsId": "aspnet5-SocialSample-20151210111056",
"publishOptions": {
"include": [
"appsettings.json",
"project.json",
"web.config"
]