google-cloud-translate 3.7.3 → 3.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +18 -2
- data/MIGRATING.md +9 -2
- data/lib/google/cloud/translate/helpers.rb +11 -3
- data/lib/google/cloud/translate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f8cf7a32f30be7ebe4466d97398218d0a0b5844af24f2b3dbc44bef1d5edd6f7
|
|
4
|
+
data.tar.gz: d9032461d1e52515cce444ca2e407721b53ffb02d4ad8349e82b0b0640214c7b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f835ce290535e817714c4b07a746f7e0bdb0bdef5bc379debac16062541cdc25f1100139952183ab36915f7bc9135f37037f638eec6895fed959d4ec0b9df342
|
|
7
|
+
data.tar.gz: 97ef3148b0fbe8a5a7172c7dfd8e3ad8394ac58be1f8cee02d234675827484ec8dab9b51e86307d33b048ea7144681718145b0e516f82988a5718f6b9c1e7e60
|
data/AUTHENTICATION.md
CHANGED
|
@@ -33,6 +33,12 @@ credentials, there are several methods available to you.
|
|
|
33
33
|
|
|
34
34
|
Credentials are accepted in the following ways, in the following order or precedence:
|
|
35
35
|
|
|
36
|
+
> [!WARNING]
|
|
37
|
+
> If you accept a credential configuration (JSON file or Hash) from an
|
|
38
|
+
> external source for authentication to Google Cloud, you must validate it before
|
|
39
|
+
> providing it to a Google API client library. Providing an unvalidated credential
|
|
40
|
+
> configuration to Google APIs can compromise the security of your systems and data.
|
|
41
|
+
|
|
36
42
|
1. Credentials specified in method arguments
|
|
37
43
|
2. Credentials specified in configuration
|
|
38
44
|
3. Credentials pointed to or included in environment variables
|
|
@@ -54,20 +60,30 @@ whenever possible.
|
|
|
54
60
|
To configure a credentials file for an individual client initialization:
|
|
55
61
|
|
|
56
62
|
```ruby
|
|
63
|
+
require "googleauth"
|
|
57
64
|
require "google/cloud/translate"
|
|
58
65
|
|
|
66
|
+
credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
|
|
67
|
+
json_key_io: ::File.open("/path/to/keyfile.json")
|
|
68
|
+
)
|
|
69
|
+
|
|
59
70
|
client = Google::Cloud::Translate.translation_service do |config|
|
|
60
|
-
config.credentials =
|
|
71
|
+
config.credentials = credentials
|
|
61
72
|
end
|
|
62
73
|
```
|
|
63
74
|
|
|
64
75
|
To configure a credentials file globally for all clients:
|
|
65
76
|
|
|
66
77
|
```ruby
|
|
78
|
+
require "googleauth"
|
|
67
79
|
require "google/cloud/translate"
|
|
68
80
|
|
|
81
|
+
credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
|
|
82
|
+
json_key_io: ::File.open("/path/to/keyfile.json")
|
|
83
|
+
)
|
|
84
|
+
|
|
69
85
|
Google::Cloud::Translate.configure do |config|
|
|
70
|
-
config.credentials =
|
|
86
|
+
config.credentials = credentials
|
|
71
87
|
end
|
|
72
88
|
|
|
73
89
|
client = Google::Cloud::Translate.translation_service
|
data/MIGRATING.md
CHANGED
|
@@ -88,11 +88,18 @@ client = Google::Cloud::Translate.new version: :v2,
|
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
New (V3):
|
|
91
|
-
```
|
|
91
|
+
```ruby
|
|
92
|
+
require "googleauth"
|
|
93
|
+
require "google/cloud/translate"
|
|
94
|
+
|
|
95
|
+
credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
|
|
96
|
+
json_key_io: ::File.open("/path/to/keyfile.json")
|
|
97
|
+
)
|
|
98
|
+
|
|
92
99
|
# Call the translation_service method to create a V3 client,
|
|
93
100
|
# and pass a block to configure the client.
|
|
94
101
|
client = Google::Cloud::Translate.translation_service do |config|
|
|
95
|
-
config.credentials =
|
|
102
|
+
config.credentials = credentials
|
|
96
103
|
end
|
|
97
104
|
|
|
98
105
|
# You can omit the block if you're keeping the default configuration
|
|
@@ -29,8 +29,11 @@ module Google
|
|
|
29
29
|
#
|
|
30
30
|
# @param [String] project_id Project identifier for the Cloud Translation service you are connecting to. If not
|
|
31
31
|
# present, the default project for the credentials is used.
|
|
32
|
-
# @param [
|
|
33
|
-
#
|
|
32
|
+
# @param [Google::Auth::Credentials] credentials A Google::Auth::Credentials
|
|
33
|
+
# object.
|
|
34
|
+
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
|
|
35
|
+
# is deprecated. Providing an unvalidated credential configuration to
|
|
36
|
+
# Google APIs can compromise the security of your systems and data.
|
|
34
37
|
# @param [String] key a public API access key (not an OAuth 2.0 token)
|
|
35
38
|
# @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the set of resources and operations that
|
|
36
39
|
# the connection can access. See [Using OAuth 2.0 to Access Google
|
|
@@ -48,12 +51,17 @@ module Google
|
|
|
48
51
|
# @return [Google::Cloud::Translate::V2::Api]
|
|
49
52
|
#
|
|
50
53
|
# @example
|
|
54
|
+
# require "googleauth"
|
|
51
55
|
# require "google/cloud/translate/v2"
|
|
52
56
|
#
|
|
57
|
+
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
|
|
58
|
+
# json_key_io: ::File.open("/path/to/keyfile.json")
|
|
59
|
+
# )
|
|
60
|
+
#
|
|
53
61
|
# translate = Google::Cloud::Translate::V2.new(
|
|
54
62
|
# version: :v2,
|
|
55
63
|
# project_id: "my-todo-project",
|
|
56
|
-
# credentials:
|
|
64
|
+
# credentials: credentials
|
|
57
65
|
# )
|
|
58
66
|
#
|
|
59
67
|
# translation = translate.translate "Hello world!", to: "la"
|