@@ -29,7 +29,7 @@ public Startup(IHostingEnvironment env)
2929 {
3030 var builder = new ConfigurationBuilder ( )
3131 . SetBasePath ( env . ContentRootPath )
32- . AddJsonFile ( "appsettings.json" ) ;
32+ . AddJsonFile ( "appsettings.json" , optional : true ) ;
3333
3434 if ( env . IsDevelopment ( ) )
3535 {
@@ -77,7 +77,14 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
7777 LoginPath = new PathString ( "/login" )
7878 } ) ;
7979
80- // You must first create an app with facebook and add it's ID and Secret to your config.json or user-secrets.
80+ if ( string . IsNullOrEmpty ( Configuration [ "facebook:appid" ] ) )
81+ {
82+ // User-Secrets: https://docs.asp.net/en/latest/security/app-secrets.html
83+ // See below for registration instructions for each provider.
84+ throw new InvalidOperationException ( "User secrets must be configured for each authentication provider." ) ;
85+ }
86+
87+ // You must first create an app with Facebook and add its ID and Secret to your user-secrets.
8188 // https://developers.facebook.com/apps/
8289 app . UseFacebookAuthentication ( new FacebookOptions
8390 {
@@ -88,7 +95,8 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
8895 SaveTokens = true ,
8996 } ) ;
9097
91- // See config.json
98+ // You must first create an app with Google and add its ID and Secret to your user-secrets.
99+ // https://console.developers.google.com/project
92100 app . UseOAuthAuthentication ( new OAuthOptions
93101 {
94102 AuthenticationScheme = "Google-AccessToken" ,
@@ -102,7 +110,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
102110 SaveTokens = true
103111 } ) ;
104112
105- // See config.json
113+ // You must first create an app with GitHub and add its ID and Secret to your user-secrets.
106114 // https://console.developers.google.com/project
107115 app . UseGoogleAuthentication ( new GoogleOptions
108116 {
@@ -120,7 +128,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
120128 }
121129 } ) ;
122130
123- // See config.json
131+ // You must first create an app with Twitter and add its key and Secret to your user-secrets.
124132 // https://apps.twitter.com/
125133 app . UseTwitterAuthentication ( new TwitterOptions
126134 {
@@ -151,32 +159,32 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
151159 Therefore, to authenticate through microsoft accounts, tryout the sample using the following URL:
152160 https://localhost:44318/
153161 */
154- // See config.json
162+ // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets.
155163 // https://apps.dev.microsoft.com/
156164 app . UseOAuthAuthentication ( new OAuthOptions
157165 {
158166 AuthenticationScheme = "Microsoft-AccessToken" ,
159167 DisplayName = "MicrosoftAccount-AccessToken" ,
160- ClientId = Configuration [ "msa :clientid" ] ,
161- ClientSecret = Configuration [ "msa :clientsecret" ] ,
168+ ClientId = Configuration [ "microsoftaccount :clientid" ] ,
169+ ClientSecret = Configuration [ "microsoftaccount :clientsecret" ] ,
162170 CallbackPath = new PathString ( "/signin-microsoft-token" ) ,
163171 AuthorizationEndpoint = MicrosoftAccountDefaults . AuthorizationEndpoint ,
164172 TokenEndpoint = MicrosoftAccountDefaults . TokenEndpoint ,
165173 Scope = { "https://graph.microsoft.com/user.read" } ,
166174 SaveTokens = true
167175 } ) ;
168176
169- // See config.json
177+ // You must first create an app with Microsoft Account and add its ID and Secret to your user-secrets.
170178 // https://azure.microsoft.com/en-us/documentation/articles/active-directory-v2-app-registration/
171179 app . UseMicrosoftAccountAuthentication ( new MicrosoftAccountOptions
172180 {
173181 DisplayName = "MicrosoftAccount" ,
174- ClientId = Configuration [ "msa :clientid" ] ,
175- ClientSecret = Configuration [ "msa :clientsecret" ] ,
182+ ClientId = Configuration [ "microsoftaccount :clientid" ] ,
183+ ClientSecret = Configuration [ "microsoftaccount :clientsecret" ] ,
176184 SaveTokens = true
177185 } ) ;
178186
179- // See config.json
187+ // You must first create an app with GitHub and add its ID and Secret to your user-secrets.
180188 // https://github.com/settings/applications/
181189 app . UseOAuthAuthentication ( new OAuthOptions
182190 {
@@ -190,7 +198,8 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
190198 SaveTokens = true
191199 } ) ;
192200
193- // See config.json
201+ // You must first create an app with GitHub and add its ID and Secret to your user-secrets.
202+ // https://github.com/settings/applications/
194203 app . UseOAuthAuthentication ( new OAuthOptions
195204 {
196205 AuthenticationScheme = "GitHub" ,
0 commit comments