1+ // Copyright(c) 2020 Google Inc.
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4+ // use this file except in compliance with the License. You may obtain a copy of
5+ // the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+ // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+ // License for the specific language governing permissions and limitations under
13+ // the License.
14+
15+ /* Google Analytics Admin API sample quickstart application.
16+
17+ Example usage:
18+ dotnet restore
19+ dotnet run
20+
21+ This application demonstrates the usage of the Analytics Admin API using
22+ service account credentials. For more information on service accounts, see
23+
24+ https://cloud.google.com/iam/docs/understanding-service-accounts
25+
26+ The following document provides instructions on setting service account
27+ credentials for your application:
28+
29+ https://cloud.google.com/docs/authentication/production
30+
31+ In a nutshell, you need to:
32+ 1. Create a service account and download the key JSON file.
33+
34+ https://cloud.google.com/docs/authentication/production#creating_a_service_account
35+
36+ 2. Provide service account credentials using one of the following options:
37+ - set the GOOGLE_APPLICATION_CREDENTIALS environment variable, the API
38+ client will use the value of this variable to find the service account key
39+ JSON file.
40+
41+ https://cloud.google.com/docs/authentication/production#setting_the_environment_variable
42+
43+ OR
44+ - manually pass the path to the service account key JSON file to the API client
45+ by specifying the keyFilename parameter in the constructor:
46+ https://cloud.google.com/docs/authentication/production#passing_the_path_to_the_service_account_key_in_code
47+
48+ */
49+
50+ // [START analyticsadmin_quickstart]
51+
52+ using Google . Analytics . Admin . V1Alpha ;
53+ using System ;
54+
55+ namespace AnalyticsSamples
56+ {
57+ class QuickStart
58+ {
59+ static void Main ( string [ ] args )
60+ {
61+ var client = AnalyticsAdminServiceClient . Create ( ) ;
62+ var response = client . ListAccounts ( new ListAccountsRequest ( ) ) ;
63+ foreach ( Account account in response )
64+ {
65+ Console . WriteLine ( "Account name: {0}" , account . Name ) ;
66+ Console . WriteLine ( "Display name: {0}" , account . DisplayName ) ;
67+ Console . WriteLine ( "Country code: {0}" , account . CountryCode ) ;
68+ Console . WriteLine ( "Update time: {0}" , account . UpdateTime ) ;
69+ Console . WriteLine ( "Create time: {0}" , account . CreateTime ) ;
70+ Console . WriteLine ( ) ;
71+ }
72+ }
73+ }
74+ }
75+ // [END analyticsadmin_quickstart]
0 commit comments