我正试图用Doorkeeper构建一个OAuth2提供程序,我想测试所有现有的流,但在第一次尝试时就被卡住了。
我正在尝试测试授权代码流。获取授权代码时一切正常,但一旦我尝试获取访问令牌,就会出现问题。下面提到的是一些步骤。
describe 'when sends an access token request' do
let(:access_params) do
{ grant_type: 'authorization_code',
code: authorization_code,
redirect_uri: application.redirect_uri }
end
let(:access_uri) { '/oauth/token' }
before { page.driver.post access_uri, access_params }
it 'returns valid json' do
pp page.source
end
我本来希望json带有最终的访问令牌,但我得到了这个错误。我很好地检查了客户和情人。我觉得一切都很好。
{"error":"invalid_client","error_description":"Client authentication failed due to unknown client, no client authentication included, or unsupported authentication method."}
你能帮我弄清楚缺了什么吗?感谢
我终于成功了。我错过了OAuth2规范的一个重要方面,即客户端必须使用基本身份验证来识别自己。我解决了在帖子之前添加它的问题,效果很好。
before do
page.driver.browser.authorize application.uid, application.secret
page.driver.post access_uri, access_params
end