我正在更改我的代码,将我的 http api 从 \'@angular/http\' 更改为 \'@angular/common/http\'。我的大多数请求都工作正常,但是无论我多么努力,为我带来刷新令牌的身份验证都不起作用......请看我的代码如下:
\n\n const headerHttp = new HttpHeaders();\n headerHttp.set(\'Content-Type\', \'application/x-www-form-urlencoded\');\n headerHttp.set(\'Authorization\', \'Basic YW5ndWxhcjphbmd1bGFy\');\n\n this.clientHttp.post(this.oauthTokenUrl,\n { username: user, password: pwd , grant_type: \'password\' },\n { headers: headerHttp, withCredentials: true })\n .subscribe(\n res => {\n console.log(res);\n },\n err => {\n console.log(\'Error occured\');\n }\n );\nRun Code Online (Sandbox Code Playgroud)\n\n但参数(用户名、密码和 grant_type )未到达服务器,并且弹出输入屏幕。
\n\n\n\n这是我的请求的结果,与 \'@angular/http\' 一起工作:
\n\n\n\n这是我的请求不起作用的结果,我在上面放置了该代码。
\n\n\n\n编辑 1 - 身份验证输入屏幕不再弹出,代码如下。
\n\nconst _params = new HttpParams()\n.set(\'grant_type\', \'password\')\n.set(\'username\', usuario)\n.set(\'password\', senha );\n\nconst _headers …Run Code Online (Sandbox Code Playgroud)