Ruby on rails 针对Zapier应用程序测试门卫oAuth2 问题:
我们如何测试Zapier cli应用程序的Door Keeper oauth2实现 背景 我有一个Rails 3应用程序。我正在尝试为应用程序创建一个Zapier客户端,我决定使用OAuth。因此,我将doorkeeper配置为生成JWT。一切看起来都很好,我能够授权和获得令牌使用重定向 我不知道如何纯粹通过控制台测试应用程序。使用用户名/密码进行授权难道不需要某种方式吗 我得到了一个应用程序生成的模板与一些小的差异Ruby on rails 针对Zapier应用程序测试门卫oAuth2 问题:,ruby-on-rails,oauth-2.0,zapier,doorkeeper,Ruby On Rails,Oauth 2.0,Zapier,Doorkeeper,我们如何测试Zapier cli应用程序的Door Keeper oauth2实现 背景 我有一个Rails 3应用程序。我正在尝试为应用程序创建一个Zapier客户端,我决定使用OAuth。因此,我将doorkeeper配置为生成JWT。一切看起来都很好,我能够授权和获得令牌使用重定向 我不知道如何纯粹通过控制台测试应用程序。使用用户名/密码进行授权难道不需要某种方式吗 我得到了一个应用程序生成的模板与一些小的差异 it('can fetch an access token', (done
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.
1)oauth2应用程序可以获取访问令牌:
有401电话亭https://ducks..com/oauth/token,触发身份验证刷新。
发生了什么:
正在启动对的POST请求https://ducks..com/oauth/token
从收到401代码https://ducks..com/oauth/token 1425毫秒后
收到的内容“{”错误“:“无效的请求”,“错误描述”:“请求缺少必需的参数,包括”
有401电话亭https://ducks..com/oauth/token,触发身份验证刷新。
这应该是因为用户未登录在测试控制台中发出的请求
我如何让用户登录?或者应该更改测试