SHARE
TWEET

Untitled

a guest Jun 20th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. serviceCollection
  2.     .AddAuthentication(o =>
  3.     {
  4.         o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
  5.         o.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
  6.     })
  7.     .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme)
  8.     .AddMicrosoftAccount("Microsoft", "Microsoft", o =>
  9.     {
  10.         o.SignInScheme = IdentityConstants.ExternalScheme;
  11.         o.ClientId = _externalKeysOptions.MicrosoftClientId;
  12.         o.ClientSecret = _externalKeysOptions.MicrosoftClientSecret;
  13.         o.CallbackPath = new PathString("/signin-microsoft");
  14.         new[]
  15.         {
  16.             "offline_access",
  17.             "Calendars.Read.Shared",
  18.             "Calendars.ReadWrite",
  19.             "Tasks.Readwrite"
  20.         }.ForEach(scope => o.Scope.Add(scope));
  21.         o.SaveTokens = true;
  22.     })
  23.      
  24. [HttpPost]
  25. [AllowAnonymous]
  26. [ValidateAntiForgeryToken]
  27. [Route("externallogin")]
  28. public IActionResult ExternalLogin(ExternalLoginModel model)
  29. {
  30.     var redirectUrl = Url.Action("ExternalLoginCallback", "Account", new { model.ReturnUrl, termsOfServiceAccepted = model.AgreeToTerms, platform = model.Platform });
  31.     var properties = _signInManager.ConfigureExternalAuthenticationProperties(model.Provider, redirectUrl);
  32.  
  33.     return Challenge(properties, model.Provider);
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top