Closed AnassL closed 6 years ago
In order to login to the token endpoint you need the 'Content-Type': 'application/x-www-form-urlencoded'.
Look in the file "endpoint-factory.service.ts" from the getLoginEndpoint
method. What do you have there?
here is the code snippet:
` getLoginEndpoint
let header = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' });
let params = new HttpParams()
.append('username', userName)
.append('password', password)
.append('grant_type', 'password')
.append('scope', 'openid email phone profile offline_access roles')
.append('resource', window.location.origin);
let requestBody = params.toString();
return this.http.post<T>(this.loginUrl, requestBody, { headers: header });
}`
Compared to the original, it's identical.
And here is the console output:
alert.service.ts:150 Severity: "error", Summary: "Unable to login", Detail: "The specified 'Content-Type' header is not valid.", Error: "{"headers":{"normalizedNames":[],"lazyUpdate":null},"status":400,"statusText":"Bad Request","url":"http://localhost:65067/connect/token","ok":false,"name":"HttpErrorResponse","message":"Http failure response for http://localhost:65067/connect/token: 400 Bad Request","error":{"error":"invalid_request","error_description":"The specified 'Content-Type' header is not valid."}}"
Checked the last build, I still can login, which means that the database data is correct.
I faced the same issue. Before, it was working even sendint application/json Content-Type. Now, even sending application/x-www-form-urlencoded is not working.
The worst thing is I can't debug it, break point on the the first line of method Exchange is never hit. Response: {"error":"invalid_request","error_description":"The mandatory 'grant_type' parameter is missing."} But as you can see on the screenshot, grant_type is set to "password".
I believe you updated openiddict nuget package to a version with a breaking change. This library was in beta and had breaking changes with each update. Its currently in rc-final and fairly stable. Update your project to the latest version of openiddict (or to the one in this repository) and also update your project to match these two files AuthorizationController.cs and endpoint-factory.service.ts
Unexpectedly and without any code change, the template stopped working. I enter the right user name and password but fail to login receiving the following error message:
Unable to login The specified 'Content-Type' header is not valid.
any idea ?