Apigee似乎不支持OAuth 2规范,是否有原因?
我们使用Apigee使用client_credentials
OAuth 2授权流程来请求持有人令牌。按照spec:Apigee似乎不支持OAuth 2规范,是否有原因?
4.4.2. Access Token Request
The client makes a request to the token endpoint by adding the
following parameters using the "application/x-www-form-urlencoded"
format per Appendix B with a character encoding of UTF-8 in the HTTP
request entity-body:
grant_type
REQUIRED. Value MUST be set to "client_credentials".
如果我们打个电话但我们得到了如下的错误:
{"ErrorCode" : "invalid_request", "Error" :"Required param : grant_type"}
看来,使用Apigee送我们到grant_type
作为查询参数。
这是为什么?由于Apigee处理OAuth 2的方式,我们有Apigee的客户无法使用他们选择的语言使用OAuth库,并且很高兴知道是否存在设计问题。
另外,它似乎不支持grant_type
在帖子正文中,并使用基本身份验证发送ID和密钥。
原来你不需要发送grant_type
作为查询参数。您的GenerateAccessToken策略中有一个接收变量的元素<GrantType>
。举例来说,我可以使用以下命令:
<OAuthV2 name="GenerateAccessToken">
<DisplayName>GenerateAccessToken</DisplayName>
<FaultRules/>
<Properties/>
<!-- This policy generates an OAuth 2.0 access token using the password grant type -->
<Operation>GenerateAccessToken</Operation>
<!-- This is in millseconds -->
<ExpiresIn>1800000</ExpiresIn>
<Attributes/>
<SupportedGrantTypes>
<GrantType>password</GrantType>
</SupportedGrantTypes>
<GenerateResponse enabled="false">
<Format>FORM_PARAM</Format>
</GenerateResponse>
<GrantType>user.grant_type</GrantType>
<UserName>request.header.username</UserName>
<PassWord>request.header.password</PassWord>
</OAuthV2>
在这个例子中,grant_type
传递作为user.grant_type
。但user.grant_type
可以是任何东西 - 头,查询参数,形式参数,甚至硬编码的值。通过这种方式,您(开发人员)在grant_type
中提供了最大的灵活性。
你可以粘贴你正在做的确切的API调用(显然你应该混淆密钥和秘密)?
我想了解当你说“Apigee”时你说的什么 - 它可能意味着API BAAS(https://api.usergrid.com)或您使用API服务定义的代理,并附加了OAuth 2策略或其他内容?
您好格雷格,这是我们附加了一个OAUthV2策略来生成访问令牌的代理。现在我期待在政策,我认为作为@我们的政策有akoo1010可能是正确的: '
工程很好,非常感谢! – Michael 2014-09-01 07:14:55