7
An update on Api
of Facebook
made the default login form of Identity
stop working. The way I’m doing that stopped working is like this:
public void ConfigureAuth(IAppBuilder app)
{
app.CreatePerOwinContext(ApplicationDbContext.Create);
app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
app.CreatePerOwinContext<ApplicationSignInManager>(ApplicationSignInManager.Create);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, Usuario,Guid>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
getUserIdCallback: (ci) => new Guid(ci.GetUserId()))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
app.UseFacebookAuthentication(new FacebookAuthenticationOptions
{
AppId = "*",
AppSecret = "*",
CallbackPath = new PathString("/Account/ExternalLoginCallback"),
Provider = new FacebookAuthenticationProvider
{
OnAuthenticated = context =>
{
context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken));
return Task.FromResult(true);
}
}
});
}
}
I want to know, a way that doesn’t use the standard implementation of identity
, to log in applications ASP.NET MVC
@Renancarlos The parameter
code
that Facebook returns to you– Randrade
@Renancarlos In this example, it will return the code here:
http://localhost:51133/Conta/Facebook
– Randrade
@Renancarlos The code facebook will return to your Controller. Look at the Login/Facebook that is in your controller that it has a code parameter, like this:
Public ActionResult Facebook(string code)
– Randrade
really the code comes as null for me.
– Renan Carlos