Google Developers Console에서 Analytics API를 사용 설정하고 내 자격 증명 (클라이언트 ID 및 클라이언트 비밀번호)을 올바르게 입력했습니다.Google Apps Script에서 웹 로그 분석에 액세스 할 수 없습니다.
이var clientId = "(censored)";
var consumerSecret = "(censored)";
var oAuthConfig = UrlFetchApp.addOAuthService('analytics');
oAuthConfig.setAccessTokenUrl("https://accounts.google.com/o/oauth2/token");
oAuthConfig.setRequestTokenUrl("https://accounts.google.com/o/oauth2/token?scope=https://www.googleapis.com/auth/analytics.readonly");
oAuthConfig.setAuthorizationUrl("https://accounts.google.com/o/oauth2/auth");
oAuthConfig.setConsumerKey(clientId);
oAuthConfig.setConsumerSecret(consumerSecret);
var url = "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:91669545&start-date=2014-12-01&end-date=2014-12-31&metrics=ga:sessions,ga:bounces";
var response = UrlFetchApp.fetch(url,{"muteHttpExceptions":true});
Logger.log(response);
내 "응답"그것도 API에서 인증 정보를 제출하지 않는 의미하는 401 오류를 반환 그렇지 않으면 내 자격 증명이 잘못되었습니다 말을 반환, 다음은 내 Google Apps 스크립트 내 코드입니다. Google Apps Script 애플리케이션에서도 다음 오류 메시지를 표시합니다.
액세스가 구성되지 않았습니다. 프로젝트에 API가 사용 설정되어 있지 않거나 IP 키당 또는 Referer 제한이 API 키에 구성되어 있으며 요청이 이러한 제한 사항과 일치하지 않습니다. Google Developers Console을 사용하여 구성을 업데이트하십시오.
oauth를 사용할 수없는 이유에 대한 아이디어가 있습니까? 감사!