通过OWIN中间件请求令牌会返回500

时间:2019-06-02 11:26:42

标签: oauth owin bearer-token owin-middleware

当我尝试通过/ token路径字符串请求令牌时得到500。

我在启动时启用了CORS。

但是尝试使用客户端应用程序(角度)检索此令牌

该请求与邮递员一起正常工作,但是当我在Angular应用程序中运行它时,我得到500响应。

在Startup.cs中,我像这样启用了cors选项

app.UseCors(CorsOptions.AllowAll);

在客户端中,这就是我尝试访问/ token端点的方式

this._http.post('https://localhost:44322/token', 'grant_type=password&username=TestName2&password=TestPassword2', {
            headers: new HttpHeaders({
                'Content-Type': 'application/x-www-form-urlencoded'
            })
        }).subscribe(response => {
            console.log('response: ', response);

期望找回令牌,但此刻我遇到以下错误:CORS策略阻止了源“ http://localhost:4200”的发出:上没有“ Access-Control-Allow-Origin”标头请求的资源。

0 个答案:

没有答案
相关问题