Ich arbeite an einer Domain-Management-Software über die OVH-API. Ich benutze nodejs und node-webkit und ich heruntergeladen die offizielle Node.js Wrapper für OVH.Verbindung über URL, testMe Funktion gibt Fehler und keine Begrüßung
Dann folgte ich die Dokumentation hier: https://www.npmjs.com/package/ovh und hier: https://eu.api.ovh.com/g934.first_step_with_api, und ich kam mit dem folgenden Code:
// 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);
}
);
}
Nun, als ich dies auszuführen, ist alles in Ordnung, bis ich versuche, durch die die Verbindung url, die testMe
Funktion sagt mir immer wieder einen Fehler und ich bekomme keine Willkommensnachricht.
Um mein Problem zu beheben, habe ich versucht, verschiedene Art und Weise zu verwenden, um meinen Code zu schreiben und sogar in OVH des Moduls Quellen geprüft, ob die Signatur direkt vor war und nach Hashing, aber es scheint alles gut zu sein ...
Wenn jemand dieses Problem bereits hatte oder wenn jemand einen Fehler in meinem Code sieht, würde ich Ihre Hilfe sehr schätzen. Dank
Behoben! Sieht aus, als hätte ich ein Problem, als es meine Schlüssel generiert hat. Aber ich habe es regeneriert und es funktioniert !! –