# Authentication Issue using Google App Script

**URL:** <http://forum.companieshouse.gov.uk/t/authentication-issue-using-google-app-script/2813>\
**Category:** API Issues\
**Created:** [January 21, 2020, 12:33am UTC](http://forum.companieshouse.gov.uk/t/authentication-issue-using-google-app-script/2813 "2020-01-21T00:33:45Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![emanuel\_cohal](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/e/ac8455/32.png) [@emanuel\_cohal](http://forum.companieshouse.gov.uk/u/emanuel_cohal)\
**Post date:** [January 22, 2020, 11:23pm UTC](http://forum.companieshouse.gov.uk/t/authentication-issue-using-google-app-script/2813/5 "2020-01-22T23:23:36Z")

</div>

Thank you for taking your time in helping me…I’ve deleted the initial API key and generated a new one…it is working now.  
Updated script, in case anyone else needs this:

function myFunction() {

var id = “SheetId”;  
var ss = SpreadsheetApp.openById(id);  
var sheet = ss.getSheetByName(“Sheet1”);

var my\_api\_key = sheet.getRange(1,2,1,1).getValue();

Logger.log(my\_api\_key);

var headers = {

“Authorization”: “Basic " + Utilities.base64Encode(my\_api\_key+”:"),

}

var params = {  
“method”:“GET”,

“headers”:headers,  
muteHttpExceptions: true,  
};

var url = “[https://api.companieshouse.gov.uk/company/00000006](https://api.companieshouse.gov.uk/company/00000006)”;

var response = JSON.parse(UrlFetchApp.fetch(url, params).getContentText());  
Logger.log(response);

}

---

_[View the full topic](http://forum.companieshouse.gov.uk/t/authentication-issue-using-google-app-script/2813)._
