I'm trying to authenticate with Instagram as an external login provider in a .Net Core 2.0 application. My middleware configuration looks like this: Startup.cs
services.AddAuthentication().AddInstagram(options =>
{
options.ClientId = ApplicationSettings.InstagramSettings.ApplicationId;
options.ClientSecret =ApplicationSettings.InstagramSettings.ApplicationSecret;
options.Scope.Add(ApplicationSettings.InstagramSettings.Permissions);
options.SaveTokens = true;
});
ExternalLogin method in AccountController is unchanged:
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public IActionResult ExternalLogin(string provider, string returnUrl = null)
{
// Request a redirect to the external login provider.
var redirectUrl = Url.Action(nameof(ExternalLoginCallback), "Account", new { returnUrl });
var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
return Challenge(properties, provider);
}
Yet, when
var info = await _signInManager.GetExternalLoginInfoAsync();
is called in the ExternalLoginCallback(), I get null as result.
NOTE:
Any ideas?
There was a bug in the version of Instagram OAuth provider that I used (2.0.0-rc2-final) that prevents the user info response from being correctly processed. I switched to the latest RTM nightly build of the package where the bug was fixed.