Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- serviceCollection
- .AddAuthentication(o =>
- {
- o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
- o.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
- })
- .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme)
- .AddMicrosoftAccount("Microsoft", "Microsoft", o =>
- {
- o.SignInScheme = IdentityConstants.ExternalScheme;
- o.ClientId = _externalKeysOptions.MicrosoftClientId;
- o.ClientSecret = _externalKeysOptions.MicrosoftClientSecret;
- o.CallbackPath = new PathString("/signin-microsoft");
- new[]
- {
- "offline_access",
- "Calendars.Read.Shared",
- "Calendars.ReadWrite",
- "Tasks.Readwrite"
- }.ForEach(scope => o.Scope.Add(scope));
- o.SaveTokens = true;
- })
- [HttpPost]
- [AllowAnonymous]
- [ValidateAntiForgeryToken]
- [Route("externallogin")]
- public IActionResult ExternalLogin(ExternalLoginModel model)
- {
- var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { model.ReturnUrl, termsOfServiceAccepted = model.AgreeToTerms, platform = model.Platform });
- var properties = _signInManager.ConfigureExternalAuthenticationProperties(model.Provider, redirectUrl);
- return Challenge(properties, model.Provider);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement