I erfolgreich implementiert Facebook und Google-Authentifizierung, aber ich mit dem Microsoft OAuth bin zu kämpfen.Externe Microsoft-Authentifizierung mit Oauth in ASP.NET 4.6; GetExternalLoginInfoAsync null zurück in ExternalLoginCallback
AuthenticationManager.GetExternalLoginInfoAsync() gibt null in ExternalLoginCallback. Hier
ist, was ich habe in Startup.Auth.cs:
MicrosoftAccountAuthenticationOptions microsoftOptions = new MicrosoftAccountAuthenticationOptions()
{
ClientId = "my-ms-ApplicationId",
ClientSecret = "my-ms-Password/Public Key",
};
microsoftOptions.Scope.Add("openid");
microsoftOptions.Scope.Add("email");
app.UseMicrosoftAccountAuthentication(microsoftOptions);
I Setup diese Route in RouteConfig.cs:
routes.MapRoute(
name: "Microsoft API Sign-in",
url: "signin-microsoft",
defaults: new { controller = "Account", action = "ExternalLoginCallbackRedirect" }
);
und
[AllowAnonymous]
public ActionResult ExternalLoginCallbackRedirect(string returnUrl)
{
return RedirectPermanent("/Account/ExternalLoginCallback");
}
Auf der Microsoft-API-Seite habe ich erstellt meine Anwendung und eine Web-Plattform mit "Allow Iimplicit Flow" ausgewählt und die Umleitungs-URL ist
auf Microsoft Graph Berechtigungen I Berechtigungen delegierte User.Read und User.ReadBasic. Alle.
Wenn ich auf "Anmelden bei Microsoft" klicke, werde ich erfolgreich zu Microsoft weitergeleitet, um ein Konto auszuwählen und wenn ich auf das Konto klicke, komme ich auf ExternalLoginCallback zurück und GetExternalLoginInfoAsync gibt null zurück.
Ich verwende .NET 4.6.1 und mit Microsoft.OWin 3.1.0
Was bin ich?
ich es bemerkt Berechtigungen werden Tragene für ** openid ** und ** E-Mail **, aber auch mit diesen Berechtigungen bekomme ich die gleiches Ergebnis. – pdube