OLD | NEW |
1 # Package of Google APIs | 1 Auto-generated Dart libraries for accessing [Google APIs][libs]. |
2 | 2 |
3 ## Description | |
4 | |
5 This repository contains auto-generated client libraries for accessing | |
6 Google APIs using dart. It has the usual dart package layout. | |
7 | |
8 ## Usage | 3 ## Usage |
9 | 4 |
10 The first step is to obtain oauth2 access credentials. This can be done using | 5 First, obtain OAuth 2.0 access credentials. This can be done using the |
11 the `googleapis_auth` package. Your application can access APIs on behalf of a | 6 `googleapis_auth` package. Your application can access APIs on behalf of a |
12 user or using a service account. | 7 user or using a service account. |
13 | 8 |
14 After obtaining credentials, an API from the `googleapis` package can be | 9 After obtaining credentials, an API from the `googleapis` package can be |
15 accessed with an authenticated HTTP client. | 10 accessed with an authenticated HTTP client. |
16 | 11 |
17 The following is an example of a command line application which lists files | 12 ## Example |
18 in Google Drive by using a service account. | 13 |
| 14 The following command line application lists files in Google Drive by using a |
| 15 service account. |
19 | 16 |
20 Create a `pubspec.yaml` file with the `googleapis_auth` and `googleapis` | 17 Create a `pubspec.yaml` file with the `googleapis_auth` and `googleapis` |
21 dependencies. | 18 dependencies. |
22 | 19 |
23 ... | 20 ```yaml |
24 dependencies: | 21 ... |
25 googleapis: any | 22 dependencies: |
26 googleapis_auth: any | 23 googleapis: any |
| 24 googleapis_auth: any |
| 25 ``` |
27 | 26 |
28 Create a service account in the Google Cloud Console and save the credential | 27 Create a service account in the Google Cloud Console and save the credential |
29 information. After that the Cloud Storage API can be accessed like this: | 28 information. |
30 | 29 |
31 import 'package:googleapis/storage/v1.dart'; | 30 Then create a Dart application to list files in a spececific project. *In the |
32 import 'package:googleapis_auth/auth_io.dart'; | 31 example below, files from the `dart-on-cloud` project are listed.* |
33 | 32 |
34 final Credentials = new ServiceAccountCredentials.fromJson(r''' | 33 ```dart |
35 { | 34 // bin/list_files.dart |
36 "private_key_id": ..., | |
37 "private_key": ..., | |
38 "client_email": ..., | |
39 "client_id": ..., | |
40 "type": "service_account" | |
41 } | |
42 '''); | |
43 | 35 |
44 void main() { | 36 import 'package:googleapis/storage/v1.dart'; |
45 clientViaServiceAccount(Credentials, | 37 import 'package:googleapis_auth/auth_io.dart'; |
46 [StorageApi.DevstorageReadOnlyScope]).then((http)
{ | 38 |
47 var storage = new StorageApi(http); | 39 final _credentials = new ServiceAccountCredentials.fromJson(r''' |
48 storage.buckets.list('dart-on-cloud').then((buckets) { | 40 { |
49 print("Received ${buckets.items.length} bucket names:"); | 41 "private_key_id": ..., |
50 for (var file in buckets.items) { | 42 "private_key": ..., |
51 print(file.name); | 43 "client_email": ..., |
52 } | 44 "client_id": ..., |
53 }); | 45 "type": "service_account" |
54 }); | 46 } |
55 } | 47 '''); |
| 48 |
| 49 const _SCOPES = const [StorageApi.DevstorageReadOnlyScope]; |
| 50 |
| 51 void main() { |
| 52 clientViaServiceAccount(_credentials, _SCOPES).then((http_client) { |
| 53 var storage = new StorageApi(http_client); |
| 54 storage.buckets.list('dart-on-cloud').then((buckets) { |
| 55 print("Received ${buckets.items.length} bucket names:"); |
| 56 for (var file in buckets.items) { |
| 57 print(file.name); |
| 58 } |
| 59 }); |
| 60 }); |
| 61 } |
| 62 ``` |
| 63 |
| 64 [libs]: https://developers.google.com/discovery/libraries/ |
56 | 65 |
57 ## Available Google APIs | 66 ## Available Google APIs |
58 | 67 |
59 The following is a list of APIs that are currently available inside this | 68 The following is a list of APIs that are currently available inside this |
60 package. | 69 package. |
61 | 70 |
62 ####  Ad
Exchange Buyer API - adexchangebuyer v1.3 | 71 ####  Ad
Exchange Buyer API - adexchangebuyer v1.3 |
63 | 72 |
64 Accesses your bidding-account information, submits creatives for validation, fin
ds available direct deals, and retrieves performance reports. | 73 Accesses your bidding-account information, submits creatives for validation, fin
ds available direct deals, and retrieves performance reports. |
65 | 74 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 ####  Driv
e API - drive v2 | 233 ####  Driv
e API - drive v2 |
225 | 234 |
226 The API to interact with Drive. | 235 The API to interact with Drive. |
227 | 236 |
228 Official API documentation: https://developers.google.com/drive/ | 237 Official API documentation: https://developers.google.com/drive/ |
229 | 238 |
230 ####  Fitness -
fitness v1 | 239 ####  Fitness -
fitness v1 |
231 | 240 |
232 Google Fit API | 241 Google Fit API |
233 | 242 |
| 243 Official API documentation: https://developers.google.com/fit/rest/ |
| 244 |
234 ####  Freebas
e Search - freebase v1 | 245 ####  Freebas
e Search - freebase v1 |
235 | 246 |
236 Find Freebase entities using textual queries and other constraints. | 247 Find Freebase entities using textual queries and other constraints. |
237 | 248 |
238 Official API documentation: https://developers.google.com/freebase/ | 249 Official API documentation: https://developers.google.com/freebase/ |
239 | 250 |
240 ####  Fusion Ta
bles API - fusiontables v1 | 251 ####  Fusion Ta
bles API - fusiontables v1 |
241 | 252 |
242 API for working with Fusion Tables data. | 253 API for working with Fusion Tables data. |
243 | 254 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 Programmatic access to YouTube features. | 403 Programmatic access to YouTube features. |
393 | 404 |
394 Official API documentation: https://developers.google.com/youtube/v3 | 405 Official API documentation: https://developers.google.com/youtube/v3 |
395 | 406 |
396 ####  YouTube
Analytics API - youtubeAnalytics v1 | 407 ####  YouTube
Analytics API - youtubeAnalytics v1 |
397 | 408 |
398 Retrieve your YouTube Analytics reports. | 409 Retrieve your YouTube Analytics reports. |
399 | 410 |
400 Official API documentation: http://developers.google.com/youtube/analytics/ | 411 Official API documentation: http://developers.google.com/youtube/analytics/ |
401 | 412 |
OLD | NEW |