Ich sende eine Anfrage von meiner MVC-Anwendung an meine WebAPI, wo OAuth2 implementiert ist. Antrag ist so etwas wie:ASP.NET WebAPI - OAuth gibt "error" zurück: "invalid_grant" nach Bestätigungserfolg
Content-Type: application/application/x-www-form-urlencoded
Accept: application/json
grant_type:password
username:someusername
password:somepassword
alles in Ordnung ist, Benutzer mit einem Erfolg bestätigt, aber die Reaktion, die zu meinem MVC zurückgibt, ist:
StatusCode:BadRequest
Content:invalid_grant
CORS erlaubt:
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
Keine Ahnung, was los ist. Es funktionierte ziemlich gut vor ...
Ich habe einen Fehler in der Post (nur). Ich benutze die Anwendung/x-www-form-urlencoded – Marox
OK, dann ist die einzige verbleibende Sache für Sie, Ihre Payload zu reparieren, so dass es den 'application/x-www-form-urlencoded' Inhaltstyp respektiert, wie in meiner Antwort gezeigt: 'grant_type = password & username = beliebigerbenutzername & password = somepassword' –
' POST/api/Token HTTP/1.1 Host: localhost: 57742 Content-Type: application/x-www-form-urlencoded Accept: application/json Cache-Control: no-cache Postman-Token: c4358da6-4ac7-2fea-eb36-7d9964208cf6 grant_type = Passwort & username = jacek% 40example.com & password =% 242a% 2410% 24bVkBdoNTxdh3jbMw4twyDeefj5iOT9PkOXp6hzxyEJiIhDTjfv0Om' – Marox