Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion google-cloud-bigquery/AUTHENTICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ providing **Project ID** and **Service Account Credentials** directly in code.

**Credentials** are discovered in the following order:

> [!WARNING]
> If you accept a credential configuration (JSON file or Hash) from an
> external source for authentication to Google Cloud, you must validate it before
> providing it to a Google API client library. Providing an unvalidated credential
> configuration to Google APIs can compromise the security of your systems and data.

1. Specify credentials in method arguments
2. Specify credentials in configuration
3. Discover credentials path in environment variables
Expand Down Expand Up @@ -81,11 +87,16 @@ The **Project ID** and the path to the **Credentials JSON** file can be configur
instead of placing them in environment variables or providing them as arguments.

```ruby
require "googleauth"
require "google/cloud/bigquery"

credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: ::File.open("/path/to/keyfile.json")
)

Google::Cloud::Bigquery.configure do |config|
config.project_id = "my-project-id"
config.credentials = "path/to/keyfile.json"
config.credentials = credentials
end

bigquery = Google::Cloud::Bigquery.new
Expand Down
22 changes: 19 additions & 3 deletions google-cloud-bigquery/lib/google-cloud-bigquery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,25 @@ def bigquery scope: nil, retries: nil, timeout: nil
#
# @param [String] project_id Identifier for a BigQuery project. If not
# present, the default project for the credentials is used.
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
# the keyfile as a String, the contents of the keyfile as a Hash, or a
# Google::Auth::Credentials object. (See {Bigquery::Credentials})
# @param [Google::Auth::Credentials] credentials A Google::Auth::Credentials
# object. (See {Bigquery::Credentials})
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
# is deprecated. Providing an unvalidated credential configuration to
# Google APIs can compromise the security of your systems and data.
#
# @example
#
# # The recommended way to provide credentials is to use the `make_creds` method
# # on the appropriate credentials class for your environment.
#
# require "googleauth"
#
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
# json_key_io: ::File.open("/path/to/keyfile.json")
# )
#
# client = ::Google::Cloud::Bigquery.new credentials: credentials
#
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
# set of resources and operations that the connection can access. See
# [Using OAuth 2.0 to Access Google
Expand Down
34 changes: 25 additions & 9 deletions google-cloud-bigquery/lib/google/cloud/bigquery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,26 @@ module Bigquery
#
# @param [String] project_id Identifier for a BigQuery project. If not
# present, the default project for the credentials is used.
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
# the keyfile as a String, the contents of the keyfile as a Hash, or a
# Google::Auth::Credentials object. (See {Bigquery::Credentials})
# @param [Google::Auth::Credentials] credentials A Google::Auth::Credentials
# object. (See {Bigquery::Credentials})
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
# is deprecated. Providing an unvalidated credential configuration to
# Google APIs can compromise the security of your systems and data.
#
# @example
#
# # The recommended way to provide credentials is to use the `make_creds` method
# # on the appropriate credentials class for your environment.
#
# require "googleauth"
#
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
# json_key_io: ::File.open("/path/to/keyfile.json")
# )
#
# client = ::Google::Cloud::Bigquery.new do |config|
# config.credentials = credentials
# end
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
# the set of resources and operations that the connection can access.
# See # [Using OAuth 2.0 to Access Google #
Expand Down Expand Up @@ -98,12 +115,11 @@ def self.new project_id: nil, credentials: nil, scope: nil, retries: nil, timeou
#
# * `project_id` - (String) Identifier for a BigQuery project. (The
# parameter `project` is considered deprecated, but may also be used.)
# * `credentials` - (String, Hash, Google::Auth::Credentials) The path to
# the keyfile as a String, the contents of the keyfile as a Hash, or a
# Google::Auth::Credentials object. (See {Bigquery::Credentials}) (The
# parameter `keyfile` is considered deprecated, but may also be used.)
# * `endpoint` - (String) Override of the endpoint host name, or `nil`
# to use the default endpoint.
# * `credentials` - (Google::Auth::Credentials) A Google::Auth::Credentials
# object. (See {Bigquery::Credentials})
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
# is deprecated. Providing an unvalidated credential configuration to
# Google APIs can compromise the security of your systems and data.
# * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
# the set of resources and operations that the connection can access.
# * `retries` - (Integer) Number of times to retry requests on server
Expand Down
13 changes: 12 additions & 1 deletion google-cloud-bigtable/AUTHENTICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ code.

**Credentials** are discovered in the following order:

> [!WARNING]
> If you accept a credential configuration (JSON file or Hash) from an
> external source for authentication to Google Cloud, you must validate it before
> providing it to a Google API client library. Providing an unvalidated credential
> configuration to Google APIs can compromise the security of your systems and data.

1. Specify credentials in method arguments
2. Specify credentials in configuration
3. Discover credentials path in environment variables
Expand Down Expand Up @@ -99,11 +105,16 @@ The **Project ID** and the path to the **Credentials JSON** file can be configur
instead of placing them in environment variables or providing them as arguments.

```ruby
require "googleauth"
require "google/cloud/bigtable"

credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: ::File.open("/path/to/keyfile.json")
)

Google::Cloud::Bigtable.configure do |config|
config.project_id = "my-project-id"
config.credentials = "path/to/keyfile.json"
config.credentials = credentials
end

client = Google::Cloud::Bigtable.new
Expand Down
47 changes: 31 additions & 16 deletions google-cloud-bigtable/lib/google-cloud-bigtable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,33 @@ module Cloud
# updater_proc is supplied.
# @param timeout [Integer]
# The default timeout, in seconds, for calls made through this client.
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel,
# @param credentials [Google::Auth::Credentials, GRPC::Core::Channel,
# GRPC::Core::ChannelCredentials, Proc]
# Provides the means for authenticating requests made by the client. This parameter can
# The means for authenticating requests made by the client. This parameter can
# be one of the following types.
# `Google::Auth::Credentials` uses the properties of its represented keyfile for
# authenticating requests made by this client.
# `String` will be treated as the path to the keyfile to use to construct
# credentials for this client.
# `Hash` will be treated as the contents of a keyfile to use to construct
# credentials for this client.
# `GRPC::Core::Channel` will be used to make calls through.
# `GRPC::Core::ChannelCredentials` will be used to set up the gRPC client. The channel credentials
# should already be composed with a `GRPC::Core::CallCredentials` object.
# `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the
# metadata for requests, generally, to give OAuth credentials.
# @return [Google::Cloud::Bigtable::Project]
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
# is deprecated. Providing an unvalidated credential configuration to
# Google APIs can compromise the security of your systems and data.
#
# @example
# require "google/cloud/bigtable"
# @example
#
# # The recommended way to provide credentials is to use the `make_creds` method
# # on the appropriate credentials class for your environment.
#
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
# json_key_io: ::File.open("/path/to/keyfile.json")
# )
#
# gcloud = Google::Cloud.new
# gcloud = Google::Cloud.new
#
# bigtable = gcloud.bigtable
# bigtable = gcloud.bigtable credentials: credentials
#
def bigtable scope: nil, timeout: nil, credentials: nil
credentials ||= @keyfile
Expand All @@ -83,21 +87,32 @@ def bigtable scope: nil, timeout: nil, credentials: nil
# Project identifier for the Bigtable service you
# are connecting to. If not present, the default project for the
# credentials is used.
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel,
# @param credentials [Google::Auth::Credentials, GRPC::Core::Channel,
# GRPC::Core::ChannelCredentials, Proc]
# The means for authenticating requests made by the client. This parameter can
# be one of the following types.
# `Google::Auth::Credentials` uses the properties of its represented keyfile for
# authenticating requests made by this client.
# `String` will be treated as the path to the keyfile to use to construct
# credentials for this client.
# `Hash` will be treated as the contents of a keyfile to use to construct
# credentials for this client.
# `GRPC::Core::Channel` will be used to make calls through.
# `GRPC::Core::ChannelCredentials` will be used to set up the gRPC client. The channel credentials
# should already be composed with a `GRPC::Core::CallCredentials` object.
# `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the
# metadata for requests, generally, to give OAuth credentials.
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
# is deprecated. Providing an unvalidated credential configuration to
# Google APIs can compromise the security of your systems and data.
#
# @example
#
# # The recommended way to provide credentials is to use the `make_creds` method
# # on the appropriate credentials class for your environment.
#
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
# json_key_io: ::File.open("/path/to/keyfile.json")
# )
#
# client = Google::Cloud.bigtable credentials: credentials
#
# @param scope [Array<String>]
# The OAuth 2.0 scopes controlling the set of resources and operations
# that the connection can access. See [Using OAuth 2.0 to Access Google
Expand Down
7 changes: 3 additions & 4 deletions google-cloud-bigtable/lib/google/cloud/bigtable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ module Bigtable
# be one of the following types:
# `Google::Auth::Credentials` uses the properties of its represented keyfile for
# authenticating requests made by this client.
# `String` will be treated as the path to the keyfile to use to construct
# credentials for this client.
# `Hash` will be treated as the contents of a keyfile to use to construct
# credentials for this client.
# `GRPC::Core::Channel` will be used to make calls through.
# `GRPC::Core::ChannelCredentials` for the setting up the gRPC client. The channel credentials
# should already be composed with a `GRPC::Core::CallCredentials` object.
# `Proc` will be used as an updater_proc for the gRPC channel. The proc transforms the
# metadata for requests, generally, to give OAuth credentials.
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
# is deprecated. Providing an unvalidated credential configuration to
# Google APIs can compromise the security of your systems and data.
# @param universe_domain [String] Override of the universe domain. Optional.
# @param endpoint [String] Override of the endpoint host name. Optional.
# If the param is nil, uses the default endpoint.
Expand Down
13 changes: 12 additions & 1 deletion google-cloud-datastore/AUTHENTICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ code.

**Credentials** are discovered in the following order:

> [!WARNING]
> If you accept a credential configuration (JSON file or Hash) from an
> external source for authentication to Google Cloud, you must validate it before
> providing it to a Google API client library. Providing an unvalidated credential
> configuration to Google APIs can compromise the security of your systems and data.

1. Specify credentials in method arguments
2. Specify credentials in configuration
3. Discover credentials path in environment variables
Expand Down Expand Up @@ -100,11 +106,16 @@ The **Project ID** and the path to the **Credentials JSON** file can be configur
instead of placing them in environment variables or providing them as arguments.

```ruby
require "googleauth"
require "google/cloud/datastore"

credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: ::File.open("/path/to/keyfile.json")
)

Google::Cloud::Datastore.configure do |config|
config.project_id = "my-project-id"
config.credentials = "path/to/keyfile.json"
config.credentials = credentials
end

client = Google::Cloud::Datastore.new
Expand Down
7 changes: 6 additions & 1 deletion google-cloud-datastore/OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ your code or via environment variables. Read more about the options for
connecting in the [Authentication Guide](AUTHENTICATION.md).

```ruby
require "googleauth"
require "google/cloud/datastore"

credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: ::File.open("/path/to/keyfile.json")
)

datastore = Google::Cloud::Datastore.new(
project_id: "my-todo-project",
credentials: "/path/to/keyfile.json"
credentials: credentials
)

task = datastore.find "Task", "sampleTask"
Expand Down
7 changes: 6 additions & 1 deletion google-cloud-datastore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ Instructions and configuration options are covered in the [Authentication Guide]
## Example

```ruby
require "googleauth"
require "google/cloud/datastore"

credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: ::File.open("/path/to/keyfile.json")
)

datastore = Google::Cloud::Datastore.new(
project_id: "my-todo-project",
credentials: "/path/to/keyfile.json"
credentials: credentials
)

# Create a new task to demo datastore
Expand Down
22 changes: 19 additions & 3 deletions google-cloud-datastore/lib/google-cloud-datastore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,25 @@ def datastore scope: nil, timeout: nil, database_id: nil
#
# @param [String] project_id Identifier for a Datastore project. If not
# present, the default project for the credentials is used.
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
# the keyfile as a String, the contents of the keyfile as a Hash, or a
# Google::Auth::Credentials object. (See {Datastore::Credentials})
# @param [Google::Auth::Credentials] credentials A Google::Auth::Credentials
# object. (See {Datastore::Credentials})
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
# is deprecated. Providing an unvalidated credential configuration to
# Google APIs can compromise the security of your systems and data.
#
# @example
#
# # The recommended way to provide credentials is to use the `make_creds` method
# # on the appropriate credentials class for your environment.
#
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
# json_key_io: ::File.open("/path/to/keyfile.json")
# )
#
# datastore = Google::Cloud::Datastore.new(
# project_id: "my-project-id",
# credentials: credentials
# )
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
# set of resources and operations that the connection can access. See
# [Using OAuth 2.0 to Access Google
Expand Down
24 changes: 21 additions & 3 deletions google-cloud-datastore/lib/google/cloud/datastore.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,27 @@ module Datastore
#
# @param [String] project_id Identifier for a Datastore project. If not
# present, the default project for the credentials is used.
# @param [String, Hash, Google::Auth::Credentials] credentials The path to
# the keyfile as a String, the contents of the keyfile as a Hash, or a
# Google::Auth::Credentials object. (See {Datastore::Credentials})
# @param [Google::Auth::Credentials] credentials A Google::Auth::Credentials
# object. (See {Datastore::Credentials})
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
# is deprecated. Providing an unvalidated credential configuration to
# Google APIs can compromise the security of your systems and data.
#
# @example
#
# # The recommended way to provide credentials is to use the `make_creds` method
# # on the appropriate credentials class for your environment.
#
# require "googleauth"
#
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
# json_key_io: ::File.open("/path/to/keyfile.json")
# )
#
# datastore = Google::Cloud::Datastore.new(
# project_id: "my-project-id",
# credentials: credentials
# )
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling
# the set of resources and operations that the connection can access.
# See [Using OAuth 2.0 to Access Google
Expand Down
13 changes: 12 additions & 1 deletion google-cloud-dns/AUTHENTICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ providing **Project ID** and **Service Account Credentials** directly in code.

**Credentials** are discovered in the following order:

> [!WARNING]
> If you accept a credential configuration (JSON file or Hash) from an
> external source for authentication to Google Cloud, you must validate it before
> providing it to a Google API client library. Providing an unvalidated credential
> configuration to Google APIs can compromise the security of your systems and data.

1. Specify credentials in method arguments
2. Specify credentials in configuration
3. Discover credentials path in environment variables
Expand Down Expand Up @@ -82,11 +88,16 @@ The **Project ID** and **Credentials JSON** can be configured instead of placing
them in environment variables or providing them as arguments.

```ruby
require "googleauth"
require "google/cloud/dns"

credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
json_key_io: ::File.open("/path/to/keyfile.json")
)

Google::Cloud::Dns.configure do |config|
config.project_id = "my-project-id"
config.credentials = "path/to/keyfile.json"
config.credentials = credentials
end

dns = Google::Cloud::Dns.new
Expand Down
Loading
Loading