Je travaille sur un logiciel de gestion de domaine via l'API OVH. J'utilise nodejs et noeud-webkit et je téléchargé le officiel Node.js wrapper pour OVH.Connexion via url, la fonction testMe génère une erreur et aucun message de bienvenue
Ensuite, je suivais la documentation ici: https://www.npmjs.com/package/ovh et ici: https://eu.api.ovh.com/g934.first_step_with_api, et je suis venu avec le code suivant:
// 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);
}
);
}
Eh bien, quand j'exécute cela, tout va bien jusqu'à ce que je tente de me connecter à travers le url, la fonction testMe
continue de me dire une erreur et je ne reçois pas le message de bienvenue.
Afin de résoudre mon problème, j'ai essayé d'utiliser autre façon d'écrire mon code et même vérifié dans les sources du module OVH si la signature était juste avant et après le hachage, mais tout semble être bon ...
Si quelqu'un a déjà eu ce problème ou si quelqu'un voit une erreur dans mon code, j'apprécierais vraiment votre aide. Merci
Fixe! On dirait que j'ai eu un problème quand il a généré mes clés. Mais je l'ai régénéré angain et ça marche !! –