I have been using App Scripts to Download and insert CM360 reports into Google Sheets for a while now, but since yesterday I get the following error when running the code:
It seems that the App Scripts credentials that I use for Authorization are not longer valid. Is this an update from Google where I need to fetch the Auth credentials from my GCP project and insert into the code? Or is there something else wrong?
Example of the code I am running:
function runreport() {
var reportId = xxx;
var profileId = xxx;
var additionalParameters = {'synchronous': 'true'};
var ReportFile = DoubleClickCampaigns.Reports.Files.list(profileId, reportId);
var ReportFileID = (ReportFile.items[0].id);
var newReportFile = DoubleClickCampaigns.Files.get(reportId, ReportFileID);
if(newReportFile.urls) {var httpOptions = {'headers': {'Authorization': 'Bearer ' + ScriptApp.getOAuthToken()}};
var csvContent = UrlFetchApp.fetch(newReportFile.urls.apiUrl, httpOptions).getContentText();
var csvData = Utilities.parseCsv(csvContent);}
Logger.log(csvData);
}
Hi,
I have been using App Scripts to Download and insert CM360 reports into Google Sheets for a while now, but since yesterday I get the following error when running the code:
Exception: Unexpected error: https://www.googleapis.com/dfareporting/v3.4/reports/754893916/files/3140433817?alt=media (Code:23:56)
When looking into the URL from the error message I get the following explanation:
{ "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "errors": [ { "message": "Login Required.", "domain": "global", "reason": "required", "location": "Authorization", "locationType": "header" } ], "status": "UNAUTHENTICATED" } }
It seems that the App Scripts credentials that I use for Authorization are not longer valid. Is this an update from Google where I need to fetch the Auth credentials from my GCP project and insert into the code? Or is there something else wrong?
Example of the code I am running:
function runreport() {
var reportId = xxx; var profileId = xxx; var additionalParameters = {'synchronous': 'true'};
var ReportFile = DoubleClickCampaigns.Reports.Files.list(profileId, reportId); var ReportFileID = (ReportFile.items[0].id);
var newReportFile = DoubleClickCampaigns.Files.get(reportId, ReportFileID); if(newReportFile.urls) {var httpOptions = {'headers': {'Authorization': 'Bearer ' + ScriptApp.getOAuthToken()}}; var csvContent = UrlFetchApp.fetch(newReportFile.urls.apiUrl, httpOptions).getContentText(); var csvData = Utilities.parseCsv(csvContent);} Logger.log(csvData); }