1

我有一个关于 ASP Web API 的项目。最近我已将 swashbuckle swagger 集成到项目中。但是每次我通过 swagger 尝试 api 调用时,我都会得到以下响应:

{
  "Message": "Authorization has been denied for this request."
}

这是请求标头:

{
   "date": "Fri, 11 Mar 2016 03:53:41 GMT",
   "www-authenticate": "Bearer",
   "x-sourcefiles": "=?UTF-8?B?YzpcdXNlcnNcaXRzYW5cZG9jdW1lbnRzXHZpc3VhbCBzdHVkaW8gMjAxM1xQcm9qZWN0c1xMZWFybldlYkFQSVxMZWFybldlYkFQSVxhcGlcVmFsdWVz?=",
   "server": "Microsoft-IIS/8.0",
   "x-powered-by": "ASP.NET",
   "content-length": "61",
   "content-type": "application/json; charset=utf-8"
}

我的 startup.cs 如下所示:

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        ConfigureAuth(app);

        var config = new HttpConfiguration();
        WebApiConfig.Register(config);
        app.UseWebApi(config);
    }
}

如果我想通过默认查看 api 调用,一切都很好。任何身体都可以提供帮助。

先谢谢了。

4

0 回答 0