我正在尝试使用OAuth2 grant_type =密码作为令牌请求,如使用WSO2 API Manager所述here . 使用以下curl命令 .
curl -k -d "grant_type=password&username=<uname>&password=<pwd>&scope=PRODUCTION" http://localhost:8280/token
该请求的回复是:
{"error":"invalid_request","error_description":"Missing parameters: client_id"}
接下来,我提供了我的消费者密钥,curl请求变为以下内容:
curl -k -d "grant_type=password&username=<uname>&password=<pwd>&scope=PRODUCTION&client_id=<myconsumerkey>" http://localhost:8280/token
但是,回应令人费解:
{"error":"unsupported_client_authentication_method","error_description":"Unsupported Client Authentication Method!"}
所以,我的问题是API Man不支持这个grant_type吗?或者,我在这里做错了吗?我应该查看此授权类型的身份服务器吗?
干杯
1 回答
您希望在HTTP基本授权标头中发送客户端凭据(客户端密钥和密钥) . 卷曲命令将如下所示 . 这里使用了“--user client-Key:client-Secret”来使用curl命令创建Basic Authorization头 . 您可以对值使用以下命令 .
再加上这个,我猜WSO2API不支持在请求体中接收客户端凭据 . 根据OAuth 2.0规范,不推荐使用 . 请检查here