Google Analytics 데이터보고 자동화를 위해 Google Analytics v3 API를 사용하고 있습니다. 내가 그것을 작동하고 간단한 API 액세스가 사용 V2.4 버전 구현이있을 때Google 웹 로그 분석 v3 Google.Apis.Requests.RequestError 사용자에게 Google 웹 로그 분석 계정이 없습니다. [403]
string scope_url = "https://www.googleapis.com/auth/analytics.readonly";
string client_id = "[email protected]";
string key_file = @"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-privatekey.p12";
string key_pass = "notasecret";
AuthorizationServerDescription desc = GoogleAuthenticationServer.Description;
//key: Load up and decrypt the key
X509Certificate2 key = new X509Certificate2(key_file, key_pass, X509KeyStorageFlags.Exportable);
//client: we're using the AssertionFlowClient, because we're logging in with our certificate
AssertionFlowClient client = new AssertionFlowClient(desc, key) { ServiceAccountId = client_id, Scope = scope_url };
OAuth2Authenticator<AssertionFlowClient> auth = new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);
//gas: An instance of the AnalyticsService we can query
// AnalyticsService gas = null;// new AnalyticsService(auth);//not compile
var gas = new AnalyticsService(new BaseClientService.Initializer()
{
Authenticator = auth
});
//r: Creating our query
DataResource.GaResource.GetRequest r = gas.Data.Ga.Get("ga:xxxxxxxx", "2012-09-26", "2012-10-10", "ga:visitors");
//d: Execute and fetch the results of our query
GaData d = r.Fetch();
나는 동일한 계정으로 오류 Google.Apis.Requests.RequestError User does not have any Google Analytics account. [403] Errors [ Message[User does not have any Google Analytics account.] Location[ - ] Reason[insufficientPermissions] Domain[global]]
얻고있다. v3.4 버전의 analytics API가 아닌 이유에서 v2.4 버전에서 작동하는 이유를 모릅니다. 내가 구글 분석 인터페이스에서 [위의 코드 클라이언트 ID에] 이메일 ID를 추가 한 후 데이터를 추출 할 수 있었다
Google Analytics 등록을위한 Infact 두 개의 다른 웹 사이트에 대한 데이터를 가져 오는 계정이 있습니다. 두 계정에 이메일 계정을 등록해야합니다. –