ovh / node-ovh

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

ovh sms node js : Got error 403: 'This call has not been granted'. #22

Closed prakashsam closed 6 years ago

prakashsam commented 6 years ago

Create app key, app secret key and consumer key and configured then cal this function i got error 403: 'This call has not been granted'.

var ovh = require('ovh')({
  appKey: 'your_app_key',
  appSecret: 'your_app_secret',
  consumerKey: 'your_consumer_key'
});

 // Get the serviceName (name of your sms account)
ovh.request('GET', '/sms', function (err, serviceName) {
  if(err) {
    console.log(err, serviceName);
  }
  else {
    console.log("My account SMS is " + serviceName);

    // Send a simple SMS with a short number using your serviceName
    ovh.request('POST', '/sms/' + serviceName + '/jobs', {
      message: 'Hello World!',
      senderForResponse: true,
      receivers: ['0033600000000']
    }, function (errsend, result) {
      console.log(errsend, result);
    });
  }
});
bnjjj commented 6 years ago

Have you already granted calls before like this ? It should be just one time. See Readme for more informations

var ovh = require('ovh')({
  endpoint: 'ovh-eu',
  appKey: 'YOUR_APP_KEY',
  appSecret: 'YOUR_APP_SECRET'
});

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);
});
prakashsam commented 6 years ago

Hi Bnjjj, Using this Url : https://eu.api.ovh.com/createToken/ i got right access for POST method then i got app key, app secret key and consumer key. or need to call every time in below code if i call below code i got every time new consumer key...using this CK in below Send sms API

var ovh = require('ovh')({
  endpoint: 'ovh-eu',
  appKey: 'YOUR_APP_KEY',
  appSecret: 'YOUR_APP_SECRET'
});

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);
});
//Send sms API
 ovh.request('GET', '/me', function (err, me) {
            console.log(err || me);
          });

        ovh.request('POST', '/sms/{serviceName}/jobs', {
            serviceName: 'sms-aaXXXXX-1',
            message: 'sms testing ',
            sender: 'Foo',
            receivers: ['+3360000000']
        }, function (err, result) {
            console.log(err || result);
        });
bnjjj commented 6 years ago

Call the first part just one time in order to get you CK.

prakashsam commented 6 years ago

But i got app and consumer keys from this https://eu.api.ovh.com/createToken/ url right acces for GET /sms/ GET/sms//jobs/ POST /sms//jobs/

Got same error 403: 'This call has not been granted' 1.First time generated consumer key using code onyl GET access

var ovh = require('ovh')({ endpoint: 'ovh-eu', appKey: 'YOUR_APP_KEY', appSecret: 'YOUR_APP_SECRET' });

ovh.request('POST', '/auth/credential', { 'accessRules': [ { 'method': 'GET', 'path': '/*'}, ] }, function (error, credential) { console.log(error || credential); });

  1. Second time using this https://eu.api.ovh.com/createToken/ get for GET,POST method right access and got new APP and consumer keys.. using this keys call the service and got error 403: 'This call has not been granted

Anything Wrong?

prakashsam commented 6 years ago

Hi Bnjjj, Can i create another app using https://ca.api.kimsufi.com/createApp/ and try again ?? #

bnjjj commented 6 years ago

Yes but make sure to use the good endpoint param. Not ‘ovh-eu’

prakashsam commented 6 years ago

Yes got it, development center in India, for this application only use for France. can i use this endpoint : https://eu.api.ovh.com or endpoint: 'ovh-eu',

bnjjj commented 6 years ago

yes if you have an eu ovh account

prakashsam commented 6 years ago

working fine