zapier中登录凭据的验证失败

时间:2018-02-12 08:38:32

标签: javascript node.js authentication zapier zapier-cli

这是我的authentication.js文件。在输入登录凭据时,在操作块中设置帐户时,它接受任何输入字符串和密码,因此验证失败。

var request = require('request');
var https = require('https');
var path = require('path');
var url = require('url');

const testAuth = (z , bundle) => {
  return z.request({
      url: 'https://abc.xyz.com/api/login.json',
      method:'POST',
      body:JSON.stringify({
        'ms_request':{
          'user':
          {
            'api_key':'ABCD',
            'username':bundle.authData.username,
            'password':bundle.authData.password,
          }
        }
      }),
    }).then((response) => {
      if (response.status === 401) {
        throw new Error('wrong credentials');
      }
      return response.content;
    });
};

module.exports = {
  type: 'custom',
  fields: [
    {key: 'username', label: 'Username', required: true, type: 'string'},
    {key: 'password', label: 'Password', required: true, type: 'password'}
  ],
  test: testAuth,
  connectionLabel: '{{bundle.authData.username}}'
};

    

In the given UI the action block accepts any given input string as username and password while connecting an account

0 个答案:

没有答案