AUTHENTICATION.md in google-cloud-pubsub-0.34.1 vs AUTHENTICATION.md in google-cloud-pubsub-0.35.0

- old
+ new

@@ -1,30 +1,50 @@ # Authentication In general, the google-cloud-pubsub library uses [Service Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts) -credentials to connect to Google Cloud services. When running on Compute Engine +credentials to connect to Google Cloud services. When running within [Google +Cloud Platform environments](#google-cloud-platform-environments) the credentials will be discovered automatically. When running on other environments, the Service Account credentials can be specified by providing the path to the [JSON keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys) for -the account (or the JSON itself) in environment variables. Additionally, Cloud -SDK credentials can also be discovered automatically, but this is only -recommended during development. +the account (or the JSON itself) in [environment +variables](#environment-variables). Additionally, Cloud SDK credentials can also +be discovered automatically, but this is only recommended during development. +## Quickstart + +1. [Create a service account and credentials](#creating-a-service-account). +2. Set the [environment variable](#environment-variables). + +```sh +export PUBSUB_CREDENTIALS=/path/to/json` +``` + +3. Initialize the client. + +```ruby +require "google/cloud/pubsub" + +client = Google::Cloud::PubSub.new +``` + ## Project and Credential Lookup -The google-cloud-pubsub library aims to make authentication as simple as -possible, and provides several mechanisms to configure your system without -providing **Project ID** and **Service Account Credentials** directly in code. +The google-cloud-pubsub library aims to make authentication +as simple as possible, and provides several mechanisms to configure your system +without providing **Project ID** and **Service Account Credentials** directly in +code. **Project ID** is discovered in the following order: 1. Specify project ID in method arguments 2. Specify project ID in configuration 3. Discover project ID in environment variables 4. Discover GCE project ID +5. Discover project ID in credentials JSON **Credentials** are discovered in the following order: 1. Specify credentials in method arguments 2. Specify credentials in configuration @@ -71,16 +91,16 @@ details.) The path to the **Credentials JSON** file can be stored in the environment variable, or the **Credentials JSON** itself can be stored for environments such as Docker containers where writing files is difficult or not encouraged. -The environment variables that Pub/Sub checks for project ID are: +The environment variables that google-cloud-pubsub checks for project ID are: 1. `PUBSUB_PROJECT` 2. `GOOGLE_CLOUD_PROJECT` -The environment variables that Pub/Sub checks for credentials are configured on {Google::Cloud::PubSub::V1::Credentials}: +The environment variables that google-cloud-pubsub checks for credentials are configured on {Google::Cloud::PubSub::V1::Credentials}: 1. `PUBSUB_CREDENTIALS` - Path to JSON file, or JSON contents 2. `PUBSUB_KEYFILE` - Path to JSON file, or JSON contents 3. `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents 4. `GOOGLE_CLOUD_KEYFILE` - Path to JSON file, or JSON contents @@ -90,11 +110,11 @@ require "google/cloud/pubsub" ENV["PUBSUB_PROJECT"] = "my-project-id" ENV["PUBSUB_CREDENTIALS"] = "path/to/keyfile.json" -pubsub = Google::Cloud::PubSub.new +client = Google::Cloud::PubSub.new ``` ### Configuration The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments. @@ -105,11 +125,11 @@ Google::Cloud::PubSub.configure do |config| config.project_id = "my-project-id" config.credentials = "path/to/keyfile.json" end -pubsub = Google::Cloud::PubSub.new +client = Google::Cloud::PubSub.new ``` ### Cloud SDK This option allows for an easy way to authenticate during development. If @@ -138,10 +158,11 @@ Google Cloud requires a **Project ID** and **Service Account Credentials** to connect to the APIs. You will use the **Project ID** and **JSON key file** to connect to most services with google-cloud-pubsub. -If you are not running this client on Google Compute Engine, you need a Google +If you are not running this client within [Google Cloud Platform +environments](#google-cloud-platform-environments), you need a Google Developers service account. 1. Visit the [Google Developers Console][dev-console]. 1. Create a new project or click on an existing project. 1. Activate the slide-out navigation tray and select **API Manager**. From