ähnlich this question ich mit dem Server der folgenden POST sandte:"Missing Zuschuss Typ" trotz "Content-Type: application/x-www-form-urlencoded"
content-type: application/x-www-form-urlencoded
authorization: Basic dGVzdGp3dGNsaWVudGlkOlhZN2ttem9OemwxMDA=
accept: */*
Mit der Nutzlast:
{"username"="test", "password": "pw", "email": "[email protected]"}
aber ich bin immer noch
{
"error": "invalid_request",
"error_description": "Missing grant type"
}
als Antwort vom Server. Irgendeine Idee, warum das nicht funktioniert?
Beachten Sie, dass die Anforderung funktioniert, wenn ich curl
verwenden:
$ curl testjwtclientid:[email protected]:8080/oauth/token -d grant_type=password -d username=john.doe -d password=pw -v
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'testjwtclientid'
> POST /oauth/token HTTP/1.1
> Host: localhost:8080
> Authorization: Basic dGVzdGp3dGNsaWVudGlkOlhZN2ttem9OemwxMDA=
> User-Agent: curl/7.47.0
> Accept: */*
> Content-Length: 49
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 49 out of 49 bytes
< HTTP/1.1 200
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< X-Frame-Options: DENY
< Cache-Control: no-store
< Pragma: no-cache
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Thu, 02 Nov 2017 19:21:29 GMT
<
* Connection #0 to host localhost left intact
{"access_token":"<an-ugly-long-token>","token_type":"bearer","expires_in":43199,"scope":"read write","jti":"80e2b6af-d999-4fb6-a4cd-5e6ab9c3fcaa"}
Ihre Nutzdaten sollte etwas wie Grant_type = Passwort & Benutzername = John.doe & Passwort = Pw, während Sie es als JSON übergeben. Sie können https://stackoverflow.com/questions/38165131/spring-security-oauth2-accept-json für JSON-Nutzlast überprüfen –
Ich setze meinen Kommentar als Antwort, bitte akzeptieren Sie, wenn es Ihr Problem gelöst hat. –