我们如何测试Zapier cli应用程序的Doorkeeper oauth2实现?
我有一个Rails 3应用程序。我正在尝试为应用程序创建Zapier客户端,我决定使用OAuth。因此我配置了门卫以生成JWT。一切看起来都不错,我可以使用重定向来授权和获取令牌。
我不确定如何仅通过控制台测试应用程序。是否需要某种方式来授权使用用户名/密码?
我从模板中生成了一个应用程序,但有一些细微差别。
it('can fetch an access token', (done) => {
const bundle = {
inputData: {
// In production, Zapier passes along whatever code your API set in the query params when it redirects
// the user's browser to the `redirect_uri`
code: 'one_time_code',
subdomain: 'ducks'
},
environment: {
CLIENT_ID: process.env.CLIENT_ID,
CLIENT_SECRET: process.env.CLIENT_SECRET
}
};
appTester(App.authentication.oauth2Config.getAccessToken, bundle)
.then((result) => {
result.access_token.should.eql('a_token');
result.refresh_token.should.eql('a_refresh_token');
done();
})
.catch(done);
});
结果如下:
1) oauth2 app can fetch an access token:
Got 401 calling POST https://ducks.<domain>.com/oauth/token, triggering auth refresh.
What happened:
Starting POST request to https://ducks.<domain>.com/oauth/token
Received 401 code from https://ducks.<domain>.com/oauth/token after 1425ms
Received content "{"error":"invalid_request","error_description":"The request is missing a required parameter, include"
Got 401 calling POST https://ducks.<domain>.com/oauth/token, triggering auth refresh.
这应该是因为用户没有登录在测试控制台中发出的请求......
如何让用户登录?或者应该更改测试?