API Connection with Google Apps Script

Hello everyone

I’m trying to create an API connection between Binance and a Google Sheets Spreadsheet using Google Apps Script in order to retrieve data about my personal account balance.

I tried to follow all the required guidelines on the documentation, sending my apiKey, my signature generated with timestamp and de userSecret, but everytime I keep returning the same error

{ code: 0,
  msg: 'Service unavailable from a restricted location according to \'b. Eligibility\' in https://www.binance.com/en/terms. Please contact customer service if you believe you received this message in error.' }

I live in Brazil and i know that United States is on the banned countries list of Binance.

Setting up a quick code to investigate de IP locations that Google Apps Script is using, I found out that they are located on Columbus, Ohio, United States

Google doesn’t allow me to select a static ip for the requests, it randomly uses one of its own dynamic ips

Is there a turnaround for this? Can someone help me?

here is a code snippet from my request

function generateSignature(queryString = '') {
  const props = PropertiesService.getScriptProperties();
  const secret = props.getProperty('binanceSecret');

  const timestamp = new Date().getTime();
  queryString = `timestamp=${timestamp}${queryString}`;

  let signature = Utilities.computeHmacSha256Signature(queryString, secret);
  signature = signature.map(function(byte) {
    return ('0' + (byte & 0xFF).toString(16)).slice(-2);
  }).join('');

  return `timestamp=${timestamp}&signature=${signature}`;
}



function getUserData() {
  const signature = generateSignature();
  const url = `https://api1.binance.com/api/v3/ping?${signature}`; console.log(url);
  const options = {
    'method': 'GET',
    'headers': {
      'X-MBX-APIKEY': getBinanceToken(),
      'Accept': 'application/json',
    },
    'muteHttpExceptions': true
  };
  
  getExternalIpAndLocation();
  getExternalIpAndLocation();
  getExternalIpAndLocation();

  const request = UrlFetchApp.fetch(url, options);
  const data = JSON.parse(request.getContentText()); console.log(data);

  return data;
}

Hey,
I suggest using Binance.us services if changing the IP location is not possible. Otherwise, you can create an intermediary app, independent of Google Apps Script, to fetch data from the Binance API. Call this app in the Google Apps Script to obtain the desired results.