@@ -6,35 +6,25 @@ Calls are made directly to the Datastore RPC interface.
66In practice, these would be wrapped in idiomatic code.
77
88Use [ RUNME] ( RUNME ) to generate the necessary Protocol Buffer
9- and gRPC support code.
9+ and gRPC support code. It uses protoc and the Swift Protocol
10+ Buffer and gRPC plugins, so please be sure these are in your
11+ path. The plugins can be built by running ` make ` in the
12+ top-level Plugins directory.
1013
1114Calls require a Google project ID and an OAuth token.
12- Both should be specified in [ Sources/main.swift] ( Sources/main.swift ) .
1315
1416To create a project ID, visit the
1517[ Google Cloud Console] ( https://cloud.google.com/console ) .
16-
17- One easy way to get an OAuth token is to use the
18+ Then edit [ Sources/main.swift] ( Sources/main.swift ) to
19+ replace "YOUR PROJECT ID" with your project ID.
20+
21+ OAuth tokens are obtained using Google's
22+ [ Auth Library for Swift] ( https://github.com/google/auth-library-swift ) .
23+ On OS X, this package uses a locally-installed browser and
24+ a temporary web server to take a user through an OAuth signin flow.
25+ On Linux, it gets an OAuth token from the
1826[ Instance Metadata Service] ( https://cloud.google.com/compute/docs/storing-retrieving-metadata )
19- that is available in Google cloud instances, such as
27+ that is available in Google Cloud instances, such as
2028[ Google Compute Engine] ( https://cloud.google.com/compute/ )
2129or
22- [ Google Cloud Shell] ( https://cloud.google.com/shell/docs/ ) .
23- This allows you to get a short-lived service token with curl:
24-
25- curl \
26- http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token \
27- -H Metadata-Flavor:Google
28-
29- That will return something like the following:
30-
31- {"access_token":"OAUTH ACCESS TOKEN","expires_in":1799,"token_type":"Bearer"}
32-
33-
34- Put the string matching OAUTH ACCESS TOKEN in the ` authToken ` variable in
35- [ Sources/main.swift] ( Sources/main.swift ) .
36- Please note that you must run the ` curl ` command from within a Google cloud instance.
37- Once you have the OAuth token, you can use it from anywhere until it expires.
38-
39- CAUTION: Please take care to not share your OAuth token.
40- It provides access to all of your Google services.
30+ [ Google Cloud Shell] ( https://cloud.google.com/shell/docs/ ) .
0 commit comments