ovh / node-ovh

Node.js wrapper for the OVH APIs
http://ovh.github.io/node-ovh
Other
129 stars 27 forks source link

POST on storage/access give a 403 ERROR #25

Closed musicformellons closed 5 years ago

musicformellons commented 5 years ago

I do this:

var ovh = require('ovh')({
  endpoint: 'ovh-eu',
  appKey: 'myAK',
  appSecret: 'mySK',
  consumerKey: 'myCK'
});

ovh.requestPromised('GET', '/me')
.then(function (response) {
console.log('spit it out!: ', response)
})
.catch(function (err) {
console.log('ERROR!: ', err.error, err.message)
});

ovh.requestPromised('GET', '/cloud/project/myServiceName/storage/access')
.then(function (response) {
console.log('spit it out!: ', response)
})
.catch(function (err) {
console.log('ERROR!: ', err.error, err.message)
});

ovh.requestPromised('POST', '/cloud/project/myServiceName/storage/access')
.then(function (response) {
console.log('spit it out!: ', response)
})
.catch(function (err) {
console.log('ERROR!: ', err.error, err.message)
});

OUTPUT:

ERROR!:  403 This call has not been granted
spit it out!:  { ...me output...}
spit it out!:  { token: 'etc..........', endpoints: etc.}

So somehow the POST on storage/access give a 403 ERROR. Why is that?

musicformellons commented 5 years ago

You can not tell from my output that it is the POST and not the GET, but if you comment out either of them you will find that the POST gives the ERROR.

musicformellons commented 5 years ago

BTW when performing same request via: https://api.ovh.com/console/#/cloud it does work.

bnjjj commented 5 years ago

Do you have correctly configure your access rule when you generated your CK ? If it works on a GET and not on a POST ...

ovh.request('POST', '/auth/credential', {
  'accessRules': [
    { 'method': 'GET', 'path': '/*'},
    { 'method': 'POST', 'path': '/*'},
    { 'method': 'PUT', 'path': '/*'},
    { 'method': 'DELETE', 'path': '/*'}
  ]
}, function (error, credential) {
  console.log(error || credential);
});
musicformellons commented 5 years ago

Yeah... must have been it. Got new keys and now everything works. Thanks.