Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
护照JS+;Freshbooks-OAuth错误_Oauth_Passport.js - Fatal编程技术网

护照JS+;Freshbooks-OAuth错误

护照JS+;Freshbooks-OAuth错误,oauth,passport.js,Oauth,Passport.js,我想在Freshbooks.com上使用PassportJS Freshbooks使用OAuth 1.0a,因此我复制了passport linkedin repo,并试图将其转换为Freshbooks 我犯了一个我不明白的错误: failed to obtain request token (status: 400 data: Unsupported signature method specified.) Passport是否有调试开关?我还使用OAuthStrategy编写了另一个版本,

我想在Freshbooks.com上使用PassportJS

Freshbooks使用OAuth 1.0a,因此我复制了passport linkedin repo,并试图将其转换为Freshbooks

我犯了一个我不明白的错误:

failed to obtain request token (status: 400 data: Unsupported signature method specified.)
Passport是否有调试开关?我还使用OAuthStrategy编写了另一个版本,我得到了相同的错误

Freshbooks OAuth API位于以下位置:

要在模块中运行示例服务器,请执行以下操作:

git clone git@github.com:MichaelJCole/passport-freshbooks.git
npm install
npm install passport express ejs passport-oauth  
node example/login/app.js
堆栈跟踪:

failed to obtain request token (status: 400 data: Unsupported signature method specified.)
    at /home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:196:36
    at /home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:518:17
    at passBackControl (/home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:374:13)
    at IncomingMessage.<anonymous> (/home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/node_modules/oauth/lib/oauth.js:386:9)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:910:16
    at process._tickCallback (node.js:415:13)
无法获取请求令牌(状态:400数据:指定了不支持的签名方法。)
at/home/michaelcole/scm/passport-freshbooks/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:196:36
at/home/michaelcole/scm/passport freshbooks/node_modules/passport oauth/node_modules/oauth/lib/oauth.js:518:17
在passBackControl(/home/michaelcole/scm/passport freshbooks/node_modules/passport oauth/node_modules/oauth/lib/oauth.js:374:13)
在收到消息时。(/home/michaelcole/scm/passport freshbooks/node_modules/passport oauth/node_modules/oauth/lib/oauth.js:386:9)
在IncomingMessage.EventEmitter.emit(events.js:117:20)
在_stream_readable.js:910:16
在进程中调用(node.js:415:13)

好的,这看起来是因为服务器需要明文编码而不是HMAC-SHA1

解决方案是更新策略,将signatureMethod包括在内

function Strategy(options, verify) {
  options = options || {};
  options.requestTokenURL = 'https://' + options.serverName + '/oauth/oauth_request.php';
  options.accessTokenURL = 'https://' + options.serverName + '/oauth/oauth_access.php';
  options.userAuthorizationURL = 'https://' + options.serverName + '/oauth/oauth_authorize.php';
  options.signatureMethod = "PLAINTEXT";  // < ------------------------ HERE
  options.sessionKey = options.sessionKey || 'oauth:freshbooks';

  console.log(options.requestTokenURL);
功能策略(选项,验证){
选项=选项| |{};
options.requestTokenURL='https://'+options.serverName+'/oauth/oauth_request.php';
options.accessTokenURL='https://'+options.serverName+'/oauth/oauth_access.php';
options.userAuthorizationURL='https://'+options.serverName+'/oauth/oauth_authorization.php';
options.signatureMethod=“明文”//<---------------------------此处
options.sessionKey=options.sessionKey | |“oauth:freshbooks”;
log(options.requestTokenURL);

好的,这看起来是因为服务器需要明文编码而不是HMAC-SHA1

解决方案是更新策略,将signatureMethod包括在内

function Strategy(options, verify) {
  options = options || {};
  options.requestTokenURL = 'https://' + options.serverName + '/oauth/oauth_request.php';
  options.accessTokenURL = 'https://' + options.serverName + '/oauth/oauth_access.php';
  options.userAuthorizationURL = 'https://' + options.serverName + '/oauth/oauth_authorize.php';
  options.signatureMethod = "PLAINTEXT";  // < ------------------------ HERE
  options.sessionKey = options.sessionKey || 'oauth:freshbooks';

  console.log(options.requestTokenURL);
功能策略(选项,验证){
选项=选项| |{};
options.requestTokenURL='https://'+options.serverName+'/oauth/oauth_request.php';
options.accessTokenURL='https://'+options.serverName+'/oauth/oauth_access.php';
options.userAuthorizationURL='https://'+options.serverName+'/oauth/oauth_authorization.php';
options.signatureMethod=“明文”//<---------------------------此处
options.sessionKey=options.sessionKey | |“oauth:freshbooks”;
log(options.requestTokenURL);