title: Google Sheets Advanced Google Services URL Shortener 403 Error: Forbidden
body: <p>I am trying to create a small application in in Google Sheets to sorten URLs on my personal google account. I am using the following code which I found here: <a href="https://webapps.stackexchange.com/questions/76050/google-sheets-function-to-get-a-shortened-url-from-bit-ly-or-goo-gl-etc">Google Sheets Function to get a shortened URL (from Bit.ly or goo.gl etc.)</a></p>
  <pre><code>function onOpen() {
    SpreadsheetApp.getUi()
      .createMenu(&quot;Shorten&quot;)
      .addItem(&quot;Go !!&quot;,&quot;rangeShort&quot;)
      .addToUi()  
  }
  
  function rangeShort() {
    var range = SpreadsheetApp.getActiveRange(), data = range.getValues();
    var output = [];
    for(var i = 0, iLen = data.length; i &lt; iLen; i++) {
      //var url = UrlShortener.Url.insert({longUrl: data[i][0]});
      var url = UrlShortener.Url.insert({longUrl: 'www.google.com'});
      output.push([url.id]);
    }
    range.offset(0,1).setValues(output);
  }
  </code></pre>
  <p>I created a new Google Cloud Project and enabled the URL shortener API in the project and on the Google sheet. The problem is that when I try and run the code I get an err on the line: <code>var url = UrlShortener.Url.insert({longUrl: 'www.google.com'});</code></p>
  <blockquote>
  <p>error 403, message:forbidden</p>
  </blockquote>
  <p>when i try an execute the rangeShort() function. I have no idea how to fix this. Any ideas would be most appreciated! Thanks!</p>