You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(sample): Add a top-level Datastore samples README (#790)
- [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-datastore/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea. **Issue already existed**
- [x] Ensure the tests and linter pass **N/A**
- [x] Code coverage does not decrease (if any source code was changed) **N/A**
- [x] Appropriate docs were updated (if necessary) **Strictly a docs addition**
Fixes#745 ☕️
Note: I can confirm that the existing pom.xml works correctly.
The Google Cloud Shell has application default credentials from its compute instance which will allow you to run samples without having to obtain `GOOGLE_APPLICATION_CREDENTIALS`.
6
+
Go to the [Datastore Client Readme](https://github.com/googleapis/java-datastore#samples) to run each sample in the Cloud Shell.
7
+
8
+
## Running a sample at the command line
9
+
10
+
1. First set up the `GOOGLE_CLOUD_PROJECT` environment variable.
11
+
12
+
2. Obtain authentication credentials.
13
+
14
+
Create local credentials by running the following command and following the
15
+
oauth2 flow (read more about the command [here][auth_command]):
16
+
17
+
gcloud auth application-default login
18
+
19
+
Or manually set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable
20
+
to point to a service account key JSON file path.
21
+
22
+
Learn more at [Setting Up Authentication for Server to Server Production Applications][ADC].
23
+
24
+
Now you can run a sample:
25
+
26
+
1.`cd samples/snippets` - all samples are located in the `java-datastore/samples/snippets` directory.
27
+
2.`mvn compile exec:java -Dexec.mainClass="com.google.datastore.snippets.TaskList"` - this runs the [TaskList sample](https://github.com/googleapis/java-datastore/blob/master/samples/snippets/src/main/java/com/google/datastore/snippets/TaskList.java).
0 commit comments