Getting unknown method for 'food.find_id_for_barcode' from OAuth 2.0 API

344 views
Skip to first unread message

Mehmet Önler

unread,
Jul 18, 2019, 3:59:12 AM7/18/19
to FatSecret Platform API
Hey, I am trying to call the endpoint with method: 'food.find_id_for_barcode' as described in the documentation, but I am getting "Unknown method" response. I have premium access and I can access other premium methods.
Here is the response:
{
"error": {
"code": 10,
"message": "Unknown method: method 'food.find_id_for_barcode'"
}
}

Mehmet Önler

unread,
Jul 23, 2019, 2:33:25 AM7/23/19
to FatSecret Platform API
Apparently, we need to be authenticated with "barcode localization premier"  scope to be able to use the "food.find_id_for_barcode" method.

Neel Gaywala

unread,
Mar 11, 2021, 1:48:40 AM3/11/21
to FatSecret Platform API
What  should I do when I get this error on this method => food.find_id_for_barcode ?

food.get.v2 method works perfectly fine.

Response body
{
    "error": {
        "code": 14,
        "message": "Missing scope: scope 'barcode'"
    }
}

my code in nodeJS

route.get('/foodBarcode', async (req, res) => {

  // FOR FOOD.FIND ID FOR BARCODE API
  var optionsBarcode = {
  method: "POST",
  method: "POST",
  headers: { "content-type": "application/json", "Authorization": `Bearer ${sampleToken}` },
  form: {
    method: "food.find_id_for_barcode",
    barcode: `0748927052688`,
    'region': 'IN',
  },
  json: true,
  };

  request(optionsBarcode, function (error, response, body) {
  if (error) throw new Error(error);
  console.log(body);
  res.send(body);
  });
  
});



shashi shiva

unread,
Apr 27, 2021, 2:13:45 AM4/27/21
to FatSecret Platform API
neelga...@gmail.com, I too got the same error "Missing scope: scope 'barcode'" . It's more than one month(Mar 11, 2021) you posted this issue of "Missing scope: scope 'barcode'". If there is any solution please take time to post it here, it will be helpful for me and many.

Neel Gaywala

unread,
Apr 27, 2021, 7:22:03 AM4/27/21
to FatSecret Platform API
For PREMIER account only,

// FOR ACCESS TOKEN API FOOD BARCODE
var optionsTokenFoodBarcode = {
  method: "POST",
  method: "POST",
  auth: {
    user: clientID,
    password: clientSecret,
  },
  headers: { "content-type": "application/json" },
  form: {
    grant_type: "client_credentials",
    scope: "barcode",
  },
  json: true,
};



// FOR ACCESS TOKEN FOOD BARCODE
route.get('/tokenBarcode', async (req, res) => {

  request(optionsTokenFoodBarcode, function (error, response, body) {
  if (error) throw new Error(error);
  res.send(body);
  });
  
});
Reply all
Reply to author
Forward
0 new messages