2016-06-14 3 views
0

私はOVHのAPIを使用してドメイン管理ソフトウェアを操作します。 nodejsnode-webkitを使用して、Node.js OVHのラッパーをダウンロードしました。 https://eu.api.ovh.com/g934.first_step_with_api、と私は次のコードで来た:https://www.npmjs.com/package/ovhとここに:urlで接続すると、testMe関数がエラーを返し、ウェルカムメッセージが表示されません。

はその後、私はここにドキュメントを追っ

// set the ovh object with the right configuration 
var ovh = require('ovh')({ 
    endpoint: 'ovh-eu', 
    appKey: 'APP_KEY', // replace it with my key 
    appSecret: 'APP_SECRET' // replace it with my key 
}); 

ovh.request('POST', '/auth/credential', { 
    // set access rules 
    'accessRules': [ 
    {'method': 'GET', 'path': '/*'}, 
    {'method': 'POST', 'path': '/*'}, 
    {'method': 'PUT', 'path': '/*'}, 
    {'method': 'DELETE', 'path': '/*'}, 
    ] 
}, function (error, credential) { 
    // print the error if the request failed, else, print the response 
    console.log(error || credential); 
    // set the consumerKey in the ovh object 
    ovh.consumerKey = credential.consumerKey; 
    // connect on the credential.validationUrl to validate the consumerKey 
    console.log(credential.validationUrl); 

    testMe(); 
}); 


function testMe() { 
    /* 
    This fonction test a request every second 
    to check if the user connected himself 
    */ 
    ovh.requestPromised('GET', '/me') 

    .then (function (me) { 
     // if the user is connected, tell him welcome 
     console.log('Welcome ' + me.firstname); 
    } 
) 
    .catch (function (err) { 
     console.log(err); 
     // while the user is not connected, retry the request 
     setTimeout(testMe, 1000); 
    } 
); 
} 

まあ、私はこれを実行すると、私はを介して接続しようとするまで、すべてが正常ですURLは、testMe関数は私にエラーを伝え続け、私は歓迎メッセージを取得しません。

私の問題を解決するために、違う方法で自分のコードを書こうとしましたが、署名がハッシュの前後であればOVHのモジュールソースをチェックしましたが、すべてが良いと思われます...

誰かがすでにこの問題を抱えていた場合、または誰かが自分のコードでエラーが表示された場合は、本当に助けていただければ幸いです。

then (function (response) { 
     // if the user is connected, tell him welcome 
     console.log('Welcome ' + me.firstname); 
}) 

(パラメータに改称)の代わりにこれを試してください:おかげ

+0

修正済み!私の鍵が生成されたときに問題があったように見えます。しかし、私はそれを嫌悪感を再現し、それは動作します! –

答えて

0

あなたは構文エラーを持っている

then (function (me) { 
     // if the user is connected, tell him welcome 
     console.log('Welcome ' + me.firstname); 
}) 

とにかく、それはそれが正常に動作しない間違いを教えてくださいあなたは得ている。

+0

お返事ありがとうございました!私は今それを直す。残念ながら、それは私の問題を解決しない、私のコンソールは、常に私に同じエラーを言っている: "無効な署名" –

+0

ovh.consumerKeyが空ではないことを確認できますか? – richardtz

+0

はい、私は 'console.log(ovh)'を作成し、その中にconsumerKeyが表示され、http://api.ovh.com/のグラフィカルなapiで有効性がチェックされ、キーは有効なものとして書き込まれます。 –

関連する問題