授权标头中不是有效的键=值对(缺少等号) [英] not a valid key=value pair (missing equal-sign) in Authorization header
问题描述
从Postman命中API时,出现此错误.
While hitting an API from Postman I am getting this error.
https://account-perf.myglobal.com/v1 /users/00uk0khprrME7gZOU0h7/credentials/change_password
Content-Type:应用程序/json
授权:Bearer n7mbkw74jsubd7rauhptdnre
Content-Type:application/json
Authorization:Bearer n7mbkw74jsubd7rauhptdnre
类型:
POST
{"password":"Baddy125@","token":"eyJhbGci...."}
网络服务调用以生成令牌-
Edit 1:
Web-service call to generate token-
https://api-perf.myglobal.com/rest/oauth2 /v1/令牌
POST
client_id:abcd
client_secret:xyz
grant_type:client_credentials
client_id:abcd
client_secret:xyz
grant_type:client_credentials
推荐答案
每当调用任何未处理的终结点方法或资源时,我都会遇到这个问题.我的设置是一个API网关,该网关具有已定义的资源(例如/myendpoint
)和用于这些终结点的已定义方法(例如GET
).
I had this whenever any unhandled endpoint method or resource was called. My setup is an API Gateway with defined resources (e.g. /myendpoint
) and defined methods for those endpoints (e.g. GET
).
要修复此问题,我创建了一个Node.js Lambda函数,该函数只返回了404.然后在端点/
的根目录处添加了任何ANY
方法,并将其作为ANY方法的Lambda代理函数.
To fix it, I created a Node.js Lambda function that just returned a 404. Then I added any ANY
method at the root of the endpoints /
and pointed it as a Lambda proxy function to the ANY methods.
然后我添加了代理资源,例如/{proxy}
-创建资源以告诉其代理时,您可以单击一个复选框.在该资源上指向同一个Lambda函数的ANY
方法,部署API,就可以了.
Then I added a proxy resource, e.g. /{proxy}
-- there's a checkbox you can click when creating a resource to tell it to proxy. An ANY
method on that resource pointing to the same Lambda function, deploy the API, and I'm done.
现在,我得到了一个正确的HTTP 404
错误,而不是auth承载令牌错误.
Now instead of the auth bearer token error, I get a proper HTTP 404
error.
这篇关于授权标头中不是有效的键=值对(缺少等号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!