パブリック アプリケーションを介して Xero API に接続しようとしています。トークンとトークン シークレットを格納する oAuth フローを実行する別のプロセスがあり、それをこのスクリプトで使用するために使用します。
私の問題は、HTTParty 呼び出しでそのトークンを使用しようとすると、Consumer_key_unknown エラーが発生し続け、その理由がわかりません。
脚本;
require 'httparty'
def nonce_generator()
random = Random.new
random.rand(100000000000)
end
//statics for testing
XERO_API_URL = 'https://api.xero.com/api.xro/2.0/'
TOKEN = "token received back from initial oauth process"
TOKEN_SECRET = "token secret received back from initial oauth process"
XERO_CONS_KEY = "my cons key per Xero Developer/Applications page"
XERO_CONS_SECRET = "my cons secret per Xero Developer/Applications page"
AUTH = "oauth_consumer_key=#{XERO_CONS_KEY}&
oauth_token=#{TOKEN}&
oauth_token_secret=#{TOKEN_SECRET}&
oauth_signature_method=RSA-SHA1&
oauth_timestamp=#{Time.now.to_i}&
oauth_nonce=#{nonce_generator()}"
//test it works
xero_accounts = HTTParty.get("#{XERO_API_URL}/accounts", :headers => { "Authorization" => AUTH }, "Accept" => "application/json")
注: ここでは、見やすくするために AUTH を複数の行に分割しました。これらはすべて、スクリプト内の 1 行にまとめられています。
私はどちらかのためにAUTHを交換しようとしました;
AUTH = "Token #{TOKEN}"
AUTH = "Bearer #{TOKEN}"
効果なし。Bearer トークンを介して動作する Kounta API で同様のスクリプトを使用しました。
Xeroizer/Xero Gateway gem を使用することを考えましたが、どちらもあなたに代わって oAuth を実行し、それを実行することを目的として構築されていますが、別のプロセスとして既に実行しています。
どんなコメントでも大歓迎です!