From cc283f7b4c19f985d67de1f41fc9568f2bad9e40 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 3 Jul 2017 11:53:33 -0700 Subject: [PATCH] Use new Auth API (#811) --- .../ForTesting/Mocks/StartupSocialTesting.cs | 15 +++++---------- samples/MusicStore/Startup.cs | 19 +++++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs b/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs index 75ee9a19ee..c08db42f70 100644 --- a/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs +++ b/samples/MusicStore/ForTesting/Mocks/StartupSocialTesting.cs @@ -94,7 +94,8 @@ namespace MusicStore options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequireClaim("ManageStore", "Allowed").Build()); }); - services.AddFacebookAuthentication(options => + services.AddAuthentication() + .AddFacebook(options => { options.AppId = "[AppId]"; options.AppSecret = "[AppSecret]"; @@ -109,9 +110,7 @@ namespace MusicStore options.Scope.Add("email"); options.Scope.Add("read_friendlists"); options.Scope.Add("user_checkins"); - }); - - services.AddGoogleAuthentication(options => + }).AddGoogle(options => { options.ClientId = "[ClientId]"; options.ClientSecret = "[ClientSecret]"; @@ -124,9 +123,7 @@ namespace MusicStore }; options.StateDataFormat = new CustomStateDataFormat(); options.BackchannelHttpHandler = new GoogleMockBackChannelHttpHandler(); - }); - - services.AddTwitterAuthentication(options => + }).AddTwitter(options => { options.ConsumerKey = "[ConsumerKey]"; options.ConsumerSecret = "[ConsumerSecret]"; @@ -138,9 +135,7 @@ namespace MusicStore }; options.StateDataFormat = new CustomTwitterStateDataFormat(); options.BackchannelHttpHandler = new TwitterMockBackChannelHttpHandler(); - }); - - services.AddMicrosoftAccountAuthentication(options => + }).AddMicrosoftAccount(options => { options.ClientId = "[ClientId]"; options.ClientSecret = "[ClientSecret]"; diff --git a/samples/MusicStore/Startup.cs b/samples/MusicStore/Startup.cs index f9aebc926e..8b56692141 100644 --- a/samples/MusicStore/Startup.cs +++ b/samples/MusicStore/Startup.cs @@ -89,24 +89,23 @@ namespace MusicStore }); }); - services.AddFacebookAuthentication(options => + + services.AddAuthentication() + .AddFacebook(options => { options.AppId = "550624398330273"; options.AppSecret = "10e56a291d6b618da61b1e0dae3a8954"; - }); - - services.AddGoogleAuthentication(options => + }) + .AddGoogle(options => { options.ClientId = "995291875932-0rt7417v5baevqrno24kv332b7d6d30a.apps.googleusercontent.com"; options.ClientSecret = "J_AT57H5KH_ItmMdu0r6PfXm"; - }); - - services.AddTwitterAuthentication(options => + }) + .AddTwitter(options => { options.ConsumerKey = "lDSPIu480ocnXYZ9DumGCDw37"; options.ConsumerSecret = "fpo0oWRNc3vsZKlZSq1PyOSoeXlJd7NnG4Rfc94xbFXsdcc3nH"; - }); - + }) // The MicrosoftAccount service has restrictions that prevent the use of // http://localhost:5001/ for test applications. // As such, here is how to change this sample to uses http://ktesting.com:5001/ instead. @@ -121,7 +120,7 @@ namespace MusicStore // The sample app can then be run via: // dnx . web - services.AddMicrosoftAccountAuthentication(options => + .AddMicrosoftAccount(options => { // MicrosoftAccount requires project changes options.ClientId = "000000004012C08A";