google-api-client 0.52.0 → 0.53.0
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/.yardopts +0 -14
- data/CHANGELOG.md +6 -0
- data/OVERVIEW.md +36 -27
- data/generated/google/apis/accesscontextmanager_v1.rb +1 -1
- data/generated/google/apis/accesscontextmanager_v1/classes.rb +326 -0
- data/generated/google/apis/accesscontextmanager_v1/representations.rb +139 -0
- data/generated/google/apis/admin_directory_v1.rb +1 -1
- data/generated/google/apis/admin_directory_v1/service.rb +2 -2
- data/generated/google/apis/analyticsadmin_v1alpha.rb +2 -2
- data/generated/google/apis/analyticsadmin_v1alpha/classes.rb +8 -0
- data/generated/google/apis/analyticsadmin_v1alpha/representations.rb +1 -0
- data/generated/google/apis/analyticsadmin_v1alpha/service.rb +12 -1
- data/{lib/google/apis/core/logging.rb → generated/google/apis/apigateway_v1.rb} +14 -10
- data/generated/google/apis/apigateway_v1/classes.rb +1116 -0
- data/generated/google/apis/apigateway_v1/representations.rb +442 -0
- data/generated/google/apis/apigateway_v1/service.rb +1172 -0
- data/generated/google/apis/apigateway_v1beta.rb +1 -1
- data/generated/google/apis/apigateway_v1beta/classes.rb +19 -8
- data/generated/google/apis/apigateway_v1beta/representations.rb +1 -0
- data/generated/google/apis/apigee_v1.rb +1 -1
- data/generated/google/apis/apigee_v1/classes.rb +24 -22
- data/generated/google/apis/apigee_v1/service.rb +50 -48
- data/generated/google/apis/artifactregistry_v1.rb +38 -0
- data/generated/google/apis/artifactregistry_v1/classes.rb +242 -0
- data/generated/google/apis/artifactregistry_v1/representations.rb +116 -0
- data/generated/google/apis/artifactregistry_v1/service.rb +210 -0
- data/generated/google/apis/artifactregistry_v1beta1.rb +1 -1
- data/generated/google/apis/artifactregistry_v1beta1/classes.rb +0 -120
- data/generated/google/apis/artifactregistry_v1beta1/representations.rb +0 -62
- data/generated/google/apis/artifactregistry_v1beta2.rb +1 -1
- data/generated/google/apis/artifactregistry_v1beta2/classes.rb +0 -120
- data/generated/google/apis/artifactregistry_v1beta2/representations.rb +0 -62
- data/generated/google/apis/chat_v1.rb +1 -1
- data/generated/google/apis/chat_v1/service.rb +132 -0
- data/generated/google/apis/cloudasset_v1.rb +1 -1
- data/generated/google/apis/cloudasset_v1/classes.rb +326 -0
- data/generated/google/apis/cloudasset_v1/representations.rb +139 -0
- data/generated/google/apis/cloudasset_v1beta1.rb +1 -1
- data/generated/google/apis/cloudasset_v1beta1/classes.rb +326 -0
- data/generated/google/apis/cloudasset_v1beta1/representations.rb +139 -0
- data/generated/google/apis/cloudasset_v1p5beta1.rb +1 -1
- data/generated/google/apis/cloudasset_v1p5beta1/classes.rb +326 -0
- data/generated/google/apis/cloudasset_v1p5beta1/representations.rb +139 -0
- data/generated/google/apis/cloudbuild_v1.rb +1 -1
- data/generated/google/apis/cloudbuild_v1/classes.rb +3 -3
- data/generated/google/apis/cloudbuild_v1alpha1.rb +1 -1
- data/generated/google/apis/cloudbuild_v1alpha1/classes.rb +3 -3
- data/generated/google/apis/cloudbuild_v1alpha2.rb +1 -1
- data/generated/google/apis/cloudbuild_v1alpha2/classes.rb +3 -3
- data/generated/google/apis/cloudidentity_v1beta1.rb +1 -1
- data/generated/google/apis/cloudidentity_v1beta1/classes.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v1.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v1/classes.rb +0 -26
- data/generated/google/apis/cloudresourcemanager_v1/representations.rb +0 -24
- data/generated/google/apis/cloudresourcemanager_v1beta1.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v1beta1/classes.rb +0 -26
- data/generated/google/apis/cloudresourcemanager_v1beta1/representations.rb +0 -24
- data/generated/google/apis/cloudresourcemanager_v2.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v2/classes.rb +0 -26
- data/generated/google/apis/cloudresourcemanager_v2/representations.rb +0 -24
- data/generated/google/apis/cloudresourcemanager_v2beta1.rb +1 -1
- data/generated/google/apis/cloudresourcemanager_v2beta1/classes.rb +0 -26
- data/generated/google/apis/cloudresourcemanager_v2beta1/representations.rb +0 -24
- data/generated/google/apis/container_v1.rb +1 -1
- data/generated/google/apis/container_v1/classes.rb +7 -7
- data/generated/google/apis/container_v1beta1.rb +1 -1
- data/generated/google/apis/container_v1beta1/classes.rb +7 -7
- data/generated/google/apis/content_v2_1.rb +1 -1
- data/generated/google/apis/content_v2_1/classes.rb +434 -0
- data/generated/google/apis/content_v2_1/representations.rb +187 -0
- data/generated/google/apis/content_v2_1/service.rb +116 -0
- data/generated/google/apis/datacatalog_v1beta1.rb +1 -1
- data/generated/google/apis/datacatalog_v1beta1/classes.rb +6 -0
- data/generated/google/apis/datacatalog_v1beta1/representations.rb +1 -0
- data/generated/google/apis/dataflow_v1b3.rb +1 -1
- data/generated/google/apis/datalabeling_v1beta1.rb +1 -1
- data/generated/google/apis/dataproc_v1.rb +1 -1
- data/generated/google/apis/dataproc_v1/classes.rb +29 -1
- data/generated/google/apis/dataproc_v1/representations.rb +14 -0
- data/generated/google/apis/dataproc_v1/service.rb +42 -0
- data/generated/google/apis/dataproc_v1beta2.rb +1 -1
- data/generated/google/apis/dataproc_v1beta2/classes.rb +29 -1
- data/generated/google/apis/dataproc_v1beta2/representations.rb +14 -0
- data/generated/google/apis/dataproc_v1beta2/service.rb +42 -0
- data/generated/google/apis/dialogflow_v2.rb +1 -1
- data/generated/google/apis/dialogflow_v2/classes.rb +4041 -678
- data/generated/google/apis/dialogflow_v2/representations.rb +1851 -298
- data/generated/google/apis/dialogflow_v2beta1.rb +1 -1
- data/generated/google/apis/dialogflow_v2beta1/classes.rb +4047 -684
- data/generated/google/apis/dialogflow_v2beta1/representations.rb +1862 -309
- data/generated/google/apis/dialogflow_v3.rb +1 -1
- data/generated/google/apis/dialogflow_v3/classes.rb +3120 -311
- data/generated/google/apis/dialogflow_v3/representations.rb +2002 -617
- data/generated/google/apis/dialogflow_v3/service.rb +408 -0
- data/generated/google/apis/dialogflow_v3beta1.rb +1 -1
- data/generated/google/apis/dialogflow_v3beta1/classes.rb +5145 -2336
- data/generated/google/apis/dialogflow_v3beta1/representations.rb +1729 -344
- data/generated/google/apis/dialogflow_v3beta1/service.rb +408 -0
- data/generated/google/apis/dlp_v2.rb +1 -1
- data/generated/google/apis/dlp_v2/service.rb +3 -9
- data/generated/google/apis/documentai_v1beta2.rb +1 -1
- data/generated/google/apis/documentai_v1beta2/classes.rb +5 -92
- data/generated/google/apis/documentai_v1beta2/representations.rb +2 -15
- data/generated/google/apis/documentai_v1beta3.rb +1 -1
- data/generated/google/apis/documentai_v1beta3/classes.rb +5 -92
- data/generated/google/apis/documentai_v1beta3/representations.rb +2 -15
- data/generated/google/apis/gameservices_v1.rb +1 -1
- data/generated/google/apis/gameservices_v1/service.rb +14 -14
- data/generated/google/apis/gameservices_v1beta.rb +1 -1
- data/generated/google/apis/gameservices_v1beta/service.rb +14 -14
- data/generated/google/apis/localservices_v1.rb +4 -1
- data/generated/google/apis/manufacturers_v1.rb +1 -1
- data/generated/google/apis/manufacturers_v1/classes.rb +2 -2
- data/generated/google/apis/monitoring_v3.rb +1 -1
- data/generated/google/apis/monitoring_v3/classes.rb +2 -2
- data/generated/google/apis/notebooks_v1.rb +1 -1
- data/generated/google/apis/notebooks_v1/classes.rb +13 -0
- data/generated/google/apis/notebooks_v1/representations.rb +12 -0
- data/generated/google/apis/notebooks_v1/service.rb +34 -0
- data/generated/google/apis/prod_tt_sasportal_v1alpha1.rb +1 -1
- data/generated/google/apis/prod_tt_sasportal_v1alpha1/classes.rb +0 -37
- data/generated/google/apis/prod_tt_sasportal_v1alpha1/representations.rb +0 -18
- data/generated/google/apis/recommendationengine_v1beta1.rb +1 -1
- data/generated/google/apis/recommendationengine_v1beta1/service.rb +2 -1
- data/generated/google/apis/securitycenter_v1.rb +1 -1
- data/generated/google/apis/securitycenter_v1/classes.rb +18 -10
- data/generated/google/apis/securitycenter_v1/representations.rb +1 -0
- data/generated/google/apis/securitycenter_v1/service.rb +30 -30
- data/generated/google/apis/securitycenter_v1beta1.rb +1 -1
- data/generated/google/apis/securitycenter_v1beta1/classes.rb +7 -0
- data/generated/google/apis/securitycenter_v1beta1/representations.rb +1 -0
- data/generated/google/apis/securitycenter_v1beta2.rb +1 -1
- data/generated/google/apis/securitycenter_v1beta2/classes.rb +7 -0
- data/generated/google/apis/securitycenter_v1beta2/representations.rb +1 -0
- data/generated/google/apis/servicemanagement_v1.rb +1 -1
- data/generated/google/apis/servicemanagement_v1/classes.rb +11 -10
- data/generated/google/apis/sqladmin_v1beta4.rb +1 -1
- data/generated/google/apis/sqladmin_v1beta4/classes.rb +7 -7
- data/generated/google/apis/sqladmin_v1beta4/service.rb +4 -1
- data/generated/google/apis/storagetransfer_v1.rb +1 -1
- data/generated/google/apis/storagetransfer_v1/classes.rb +25 -0
- data/generated/google/apis/storagetransfer_v1/representations.rb +3 -0
- data/generated/google/apis/webmasters_v3/classes.rb +8 -0
- data/generated/google/apis/webmasters_v3/representations.rb +1 -0
- data/generated/google/apis/youtube_v3.rb +1 -1
- data/generated/google/apis/youtube_v3/classes.rb +18 -143
- data/generated/google/apis/youtube_v3/representations.rb +0 -57
- data/generated/google/apis/youtube_v3/service.rb +0 -43
- data/lib/google/apis/version.rb +1 -23
- metadata +27 -263
- data/.github/CONTRIBUTING.md +0 -31
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -36
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -21
- data/.github/ISSUE_TEMPLATE/support_request.md +0 -7
- data/.github/workflows/autoapprove.yml +0 -49
- data/.github/workflows/release-please.yml +0 -57
- data/.gitignore +0 -23
- data/.kokoro/build.bat +0 -11
- data/.kokoro/build.sh +0 -4
- data/.kokoro/continuous/common.cfg +0 -25
- data/.kokoro/continuous/linux.cfg +0 -25
- data/.kokoro/continuous/osx.cfg +0 -8
- data/.kokoro/continuous/post.cfg +0 -30
- data/.kokoro/continuous/windows.cfg +0 -29
- data/.kokoro/osx.sh +0 -4
- data/.kokoro/presubmit/common.cfg +0 -24
- data/.kokoro/presubmit/linux.cfg +0 -24
- data/.kokoro/presubmit/osx.cfg +0 -8
- data/.kokoro/presubmit/windows.cfg +0 -29
- data/.kokoro/release.cfg +0 -94
- data/.kokoro/trampoline.bat +0 -10
- data/.kokoro/trampoline.sh +0 -4
- data/.repo-metadata.json +0 -5
- data/.rspec +0 -2
- data/.rubocop.yml +0 -12
- data/.rubocop_todo.yml +0 -63
- data/CODE_OF_CONDUCT.md +0 -43
- data/Gemfile +0 -55
- data/MIGRATING.md +0 -215
- data/README.md +0 -402
- data/Rakefile +0 -131
- data/api_list_config.yaml +0 -9
- data/api_names.yaml +0 -1082
- data/bin/generate-api +0 -194
- data/docs/api-keys.md +0 -20
- data/docs/auth.md +0 -53
- data/docs/client-secrets.md +0 -69
- data/docs/getting-started.md +0 -340
- data/docs/installation.md +0 -0
- data/docs/logging.md +0 -34
- data/docs/media-upload.md +0 -25
- data/docs/oauth-installed.md +0 -191
- data/docs/oauth-server.md +0 -133
- data/docs/oauth-web.md +0 -280
- data/docs/oauth.md +0 -268
- data/docs/pagination.md +0 -29
- data/docs/performance.md +0 -25
- data/google-api-client.gemspec +0 -36
- data/lib/google/api_client/auth/installed_app.rb +0 -143
- data/lib/google/api_client/auth/key_utils.rb +0 -94
- data/lib/google/api_client/auth/storage.rb +0 -104
- data/lib/google/api_client/auth/storages/file_store.rb +0 -57
- data/lib/google/api_client/auth/storages/redis_store.rb +0 -59
- data/lib/google/api_client/client_secrets.rb +0 -176
- data/lib/google/apis.rb +0 -58
- data/lib/google/apis/core/api_command.rb +0 -209
- data/lib/google/apis/core/base_service.rb +0 -447
- data/lib/google/apis/core/batch.rb +0 -236
- data/lib/google/apis/core/composite_io.rb +0 -97
- data/lib/google/apis/core/download.rb +0 -118
- data/lib/google/apis/core/hashable.rb +0 -44
- data/lib/google/apis/core/http_command.rb +0 -447
- data/lib/google/apis/core/json_representation.rb +0 -153
- data/lib/google/apis/core/multipart.rb +0 -135
- data/lib/google/apis/core/upload.rb +0 -273
- data/lib/google/apis/errors.rb +0 -89
- data/lib/google/apis/generator.rb +0 -71
- data/lib/google/apis/generator/annotator.rb +0 -339
- data/lib/google/apis/generator/helpers.rb +0 -76
- data/lib/google/apis/generator/model.rb +0 -187
- data/lib/google/apis/generator/template.rb +0 -124
- data/lib/google/apis/generator/templates/_class.tmpl +0 -43
- data/lib/google/apis/generator/templates/_method.tmpl +0 -92
- data/lib/google/apis/generator/templates/_representation.tmpl +0 -51
- data/lib/google/apis/generator/templates/_representation_stub.tmpl +0 -17
- data/lib/google/apis/generator/templates/_representation_type.tmpl +0 -10
- data/lib/google/apis/generator/templates/classes.rb.tmpl +0 -29
- data/lib/google/apis/generator/templates/module.rb.tmpl +0 -40
- data/lib/google/apis/generator/templates/representations.rb.tmpl +0 -32
- data/lib/google/apis/generator/templates/service.rb.tmpl +0 -61
- data/lib/google/apis/options.rb +0 -116
- data/rakelib/devsite/devsite_builder.rb +0 -126
- data/rakelib/devsite/link_checker.rb +0 -64
- data/rakelib/devsite/repo_metadata.rb +0 -56
- data/rakelib/metrics.rake +0 -22
- data/rakelib/rubocop.rake +0 -10
- data/rakelib/spec.rake +0 -11
- data/rakelib/yard.rake +0 -11
- data/samples/cli/.env +0 -4
- data/samples/cli/Gemfile +0 -7
- data/samples/cli/README.md +0 -51
- data/samples/cli/google-api-samples +0 -32
- data/samples/cli/lib/base_cli.rb +0 -95
- data/samples/cli/lib/samples/adsense.rb +0 -99
- data/samples/cli/lib/samples/analytics.rb +0 -80
- data/samples/cli/lib/samples/androidpublisher.rb +0 -47
- data/samples/cli/lib/samples/bigquery.rb +0 -101
- data/samples/cli/lib/samples/calendar.rb +0 -83
- data/samples/cli/lib/samples/drive.rb +0 -82
- data/samples/cli/lib/samples/gmail.rb +0 -157
- data/samples/cli/lib/samples/pubsub.rb +0 -114
- data/samples/cli/lib/samples/sheets.rb +0 -61
- data/samples/cli/lib/samples/translate.rb +0 -44
- data/samples/cli/lib/samples/vision.rb +0 -69
- data/samples/cli/lib/samples/you_tube.rb +0 -47
- data/samples/web/Gemfile +0 -9
- data/samples/web/README.md +0 -44
- data/samples/web/app.rb +0 -120
- data/samples/web/views/calendar.erb +0 -34
- data/samples/web/views/drive.erb +0 -33
- data/samples/web/views/home.erb +0 -34
- data/samples/web/views/layout.erb +0 -40
- data/synth.py +0 -40
@@ -1,94 +0,0 @@
|
|
1
|
-
# Copyright 2010 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
module Google
|
16
|
-
class APIClient
|
17
|
-
##
|
18
|
-
# Helper for loading keys from the PKCS12 files downloaded when
|
19
|
-
# setting up service accounts at the APIs Console.
|
20
|
-
#
|
21
|
-
# @deprecated Use google-auth-library-ruby instead
|
22
|
-
module KeyUtils
|
23
|
-
##
|
24
|
-
# Loads a key from PKCS12 file, assuming a single private key
|
25
|
-
# is present.
|
26
|
-
#
|
27
|
-
# @param [String] keyfile
|
28
|
-
# Path of the PKCS12 file to load. If not a path to an actual file,
|
29
|
-
# assumes the string is the content of the file itself.
|
30
|
-
# @param [String] passphrase
|
31
|
-
# Passphrase for unlocking the private key
|
32
|
-
#
|
33
|
-
# @return [OpenSSL::PKey] The private key for signing assertions.
|
34
|
-
def self.load_from_pkcs12(keyfile, passphrase)
|
35
|
-
load_key(keyfile, passphrase) do |content, pass_phrase|
|
36
|
-
OpenSSL::PKCS12.new(content, pass_phrase).key
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
##
|
42
|
-
# Loads a key from a PEM file.
|
43
|
-
#
|
44
|
-
# @param [String] keyfile
|
45
|
-
# Path of the PEM file to load. If not a path to an actual file,
|
46
|
-
# assumes the string is the content of the file itself.
|
47
|
-
# @param [String] passphrase
|
48
|
-
# Passphrase for unlocking the private key
|
49
|
-
#
|
50
|
-
# @return [OpenSSL::PKey] The private key for signing assertions.
|
51
|
-
#
|
52
|
-
def self.load_from_pem(keyfile, passphrase)
|
53
|
-
load_key(keyfile, passphrase) do | content, pass_phrase|
|
54
|
-
OpenSSL::PKey::RSA.new(content, pass_phrase)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
##
|
61
|
-
# Helper for loading keys from file or memory. Accepts a block
|
62
|
-
# to handle the specific file format.
|
63
|
-
#
|
64
|
-
# @param [String] keyfile
|
65
|
-
# Path of thefile to load. If not a path to an actual file,
|
66
|
-
# assumes the string is the content of the file itself.
|
67
|
-
# @param [String] passphrase
|
68
|
-
# Passphrase for unlocking the private key
|
69
|
-
#
|
70
|
-
# @yield [String, String]
|
71
|
-
# Key file & passphrase to extract key from
|
72
|
-
# @yieldparam [String] keyfile
|
73
|
-
# Contents of the file
|
74
|
-
# @yieldparam [String] passphrase
|
75
|
-
# Passphrase to unlock key
|
76
|
-
# @yieldreturn [OpenSSL::PKey]
|
77
|
-
# Private key
|
78
|
-
#
|
79
|
-
# @return [OpenSSL::PKey] The private key for signing assertions.
|
80
|
-
def self.load_key(keyfile, passphrase, &block)
|
81
|
-
begin
|
82
|
-
begin
|
83
|
-
content = File.open(keyfile, 'rb') { |io| io.read }
|
84
|
-
rescue
|
85
|
-
content = keyfile
|
86
|
-
end
|
87
|
-
block.call(content, passphrase)
|
88
|
-
rescue OpenSSL::OpenSSLError
|
89
|
-
raise ArgumentError.new("Invalid keyfile or passphrase")
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,104 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'signet/oauth_2/client'
|
16
|
-
|
17
|
-
module Google
|
18
|
-
class APIClient
|
19
|
-
##
|
20
|
-
# Represents cached OAuth 2 tokens stored on local disk in a
|
21
|
-
# JSON serialized file. Meant to resemble the serialized format
|
22
|
-
# http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.file.Storage-class.html
|
23
|
-
#
|
24
|
-
# @deprecated Use google-auth-library-ruby instead
|
25
|
-
class Storage
|
26
|
-
|
27
|
-
AUTHORIZATION_URI = 'https://accounts.google.com/o/oauth2/auth'
|
28
|
-
TOKEN_CREDENTIAL_URI = 'https://accounts.google.com/o/oauth2/token'
|
29
|
-
|
30
|
-
# @return [Object] Storage object.
|
31
|
-
attr_accessor :store
|
32
|
-
|
33
|
-
# @return [Signet::OAuth2::Client]
|
34
|
-
attr_reader :authorization
|
35
|
-
|
36
|
-
##
|
37
|
-
# Initializes the Storage object.
|
38
|
-
#
|
39
|
-
# @param [Object] store
|
40
|
-
# Storage object
|
41
|
-
def initialize(store)
|
42
|
-
@store= store
|
43
|
-
@authorization = nil
|
44
|
-
end
|
45
|
-
|
46
|
-
##
|
47
|
-
# Write the credentials to the specified store.
|
48
|
-
#
|
49
|
-
# @param [Signet::OAuth2::Client] authorization
|
50
|
-
# Optional authorization instance. If not provided, the authorization
|
51
|
-
# already associated with this instance will be written.
|
52
|
-
def write_credentials(authorization=nil)
|
53
|
-
@authorization = authorization if authorization
|
54
|
-
if @authorization.respond_to?(:refresh_token) && @authorization.refresh_token
|
55
|
-
store.write_credentials(credentials_hash)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
##
|
60
|
-
# Loads credentials and authorizes an client.
|
61
|
-
# @return [Object] Signet::OAuth2::Client or NIL
|
62
|
-
def authorize
|
63
|
-
@authorization = nil
|
64
|
-
cached_credentials = load_credentials
|
65
|
-
if cached_credentials && cached_credentials.size > 0
|
66
|
-
@authorization = Signet::OAuth2::Client.new(cached_credentials)
|
67
|
-
@authorization.issued_at = Time.at(cached_credentials['issued_at'].to_i)
|
68
|
-
self.refresh_authorization if @authorization.expired?
|
69
|
-
end
|
70
|
-
return @authorization
|
71
|
-
end
|
72
|
-
|
73
|
-
##
|
74
|
-
# refresh credentials and save them to store
|
75
|
-
def refresh_authorization
|
76
|
-
authorization.refresh!
|
77
|
-
self.write_credentials
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
##
|
83
|
-
# Attempt to read in credentials from the specified store.
|
84
|
-
def load_credentials
|
85
|
-
store.load_credentials
|
86
|
-
end
|
87
|
-
|
88
|
-
##
|
89
|
-
# @return [Hash] with credentials
|
90
|
-
def credentials_hash
|
91
|
-
{
|
92
|
-
:access_token => authorization.access_token,
|
93
|
-
:authorization_uri => AUTHORIZATION_URI,
|
94
|
-
:client_id => authorization.client_id,
|
95
|
-
:client_secret => authorization.client_secret,
|
96
|
-
:expires_in => authorization.expires_in,
|
97
|
-
:refresh_token => authorization.refresh_token,
|
98
|
-
:token_credential_uri => TOKEN_CREDENTIAL_URI,
|
99
|
-
:issued_at => authorization.issued_at.to_i
|
100
|
-
}
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'json'
|
16
|
-
|
17
|
-
module Google
|
18
|
-
class APIClient
|
19
|
-
##
|
20
|
-
# Represents cached OAuth 2 tokens stored on local disk in a
|
21
|
-
# JSON serialized file. Meant to resemble the serialized format
|
22
|
-
# http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.file.Storage-class.html
|
23
|
-
#
|
24
|
-
# @deprecated Use google-auth-library-ruby instead
|
25
|
-
class FileStore
|
26
|
-
|
27
|
-
attr_accessor :path
|
28
|
-
|
29
|
-
##
|
30
|
-
# Initializes the FileStorage object.
|
31
|
-
#
|
32
|
-
# @param [String] path
|
33
|
-
# Path to the credentials file.
|
34
|
-
def initialize(path)
|
35
|
-
@path= path
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# Attempt to read in credentials from the specified file.
|
40
|
-
def load_credentials
|
41
|
-
open(path, 'r') { |f| JSON.parse(f.read) }
|
42
|
-
rescue
|
43
|
-
nil
|
44
|
-
end
|
45
|
-
|
46
|
-
##
|
47
|
-
# Write the credentials to the specified file.
|
48
|
-
#
|
49
|
-
# @param [Hash] credentials_hash
|
50
|
-
def write_credentials(credentials_hash)
|
51
|
-
open(self.path, 'w+') do |f|
|
52
|
-
f.write(credentials_hash.to_json)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# Copyright 2013 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'json'
|
16
|
-
|
17
|
-
module Google
|
18
|
-
class APIClient
|
19
|
-
# @deprecated Use google-auth-library-ruby instead
|
20
|
-
class RedisStore
|
21
|
-
|
22
|
-
DEFAULT_REDIS_CREDENTIALS_KEY = "google_api_credentials"
|
23
|
-
|
24
|
-
attr_accessor :redis
|
25
|
-
|
26
|
-
##
|
27
|
-
# Initializes the RedisStore object.
|
28
|
-
#
|
29
|
-
# @param [Object] redis
|
30
|
-
# Redis instance
|
31
|
-
# @param [Object] key
|
32
|
-
# Optional key to store credentials under. Defaults to 'google_api_credentials'
|
33
|
-
def initialize(redis, key = nil)
|
34
|
-
@redis= redis
|
35
|
-
@redis_credentials_key = key
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# Attempt to read in credentials from redis.
|
40
|
-
# @return [Hash]
|
41
|
-
def load_credentials
|
42
|
-
credentials = redis.get redis_credentials_key
|
43
|
-
JSON.parse(credentials) if credentials
|
44
|
-
end
|
45
|
-
|
46
|
-
def redis_credentials_key
|
47
|
-
@redis_credentials_key || DEFAULT_REDIS_CREDENTIALS_KEY
|
48
|
-
end
|
49
|
-
|
50
|
-
##
|
51
|
-
# Write the credentials to redis.
|
52
|
-
#
|
53
|
-
# @param [Hash] credentials_hash
|
54
|
-
def write_credentials(credentials_hash)
|
55
|
-
redis.set(redis_credentials_key, credentials_hash.to_json)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,176 +0,0 @@
|
|
1
|
-
# Copyright 2010 Google Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
|
15
|
-
require 'json'
|
16
|
-
require 'googleauth'
|
17
|
-
|
18
|
-
|
19
|
-
module Google
|
20
|
-
class APIClient
|
21
|
-
##
|
22
|
-
# Manages the persistence of client configuration data and secrets. Format
|
23
|
-
# inspired by the Google API Python client.
|
24
|
-
#
|
25
|
-
# @see https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
|
26
|
-
# @deprecated Use google-auth-library-ruby instead
|
27
|
-
# @example
|
28
|
-
# {
|
29
|
-
# "web": {
|
30
|
-
# "client_id": "asdfjasdljfasdkjf",
|
31
|
-
# "client_secret": "1912308409123890",
|
32
|
-
# "redirect_uris": ["https://www.example.com/oauth2callback"],
|
33
|
-
# "auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
34
|
-
# "token_uri": "https://accounts.google.com/o/oauth2/token"
|
35
|
-
# }
|
36
|
-
# }
|
37
|
-
#
|
38
|
-
# @example
|
39
|
-
# {
|
40
|
-
# "installed": {
|
41
|
-
# "client_id": "837647042410-75ifg...usercontent.com",
|
42
|
-
# "client_secret":"asdlkfjaskd",
|
43
|
-
# "redirect_uris": ["http://localhost", "urn:ietf:oauth:2.0:oob"],
|
44
|
-
# "auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
45
|
-
# "token_uri": "https://accounts.google.com/o/oauth2/token"
|
46
|
-
# }
|
47
|
-
# }
|
48
|
-
class ClientSecrets
|
49
|
-
##
|
50
|
-
# Reads client configuration from a file
|
51
|
-
#
|
52
|
-
# @param [String] filename
|
53
|
-
# Path to file to load
|
54
|
-
#
|
55
|
-
# @return [Google::APIClient::ClientSecrets]
|
56
|
-
# OAuth client settings
|
57
|
-
def self.load(filename=nil)
|
58
|
-
if filename && File.directory?(filename)
|
59
|
-
search_path = File.expand_path(filename)
|
60
|
-
filename = nil
|
61
|
-
end
|
62
|
-
while filename == nil
|
63
|
-
search_path ||= File.expand_path('.')
|
64
|
-
if File.exists?(File.join(search_path, 'client_secrets.json'))
|
65
|
-
filename = File.join(search_path, 'client_secrets.json')
|
66
|
-
elsif search_path == File.expand_path('..', search_path)
|
67
|
-
raise ArgumentError,
|
68
|
-
'No client_secrets.json filename supplied ' +
|
69
|
-
'and/or could not be found in search path.'
|
70
|
-
else
|
71
|
-
search_path = File.expand_path(File.join(search_path, '..'))
|
72
|
-
end
|
73
|
-
end
|
74
|
-
data = File.open(filename, 'r') { |file| JSON.load(file.read) }
|
75
|
-
return self.new(data)
|
76
|
-
end
|
77
|
-
|
78
|
-
##
|
79
|
-
# Initialize OAuth client settings.
|
80
|
-
#
|
81
|
-
# @param [Hash] options
|
82
|
-
# Parsed client secrets files
|
83
|
-
def initialize(options={})
|
84
|
-
# Client auth configuration
|
85
|
-
@flow = options[:flow] || options.keys.first.to_s || 'web'
|
86
|
-
fdata = options[@flow.to_sym] || options[@flow]
|
87
|
-
@client_id = fdata[:client_id] || fdata["client_id"]
|
88
|
-
@client_secret = fdata[:client_secret] || fdata["client_secret"]
|
89
|
-
@redirect_uris = fdata[:redirect_uris] || fdata["redirect_uris"]
|
90
|
-
@redirect_uris ||= [fdata[:redirect_uri] || fdata["redirect_uri"]].compact
|
91
|
-
@javascript_origins = (
|
92
|
-
fdata[:javascript_origins] ||
|
93
|
-
fdata["javascript_origins"]
|
94
|
-
)
|
95
|
-
@javascript_origins ||= [fdata[:javascript_origin] || fdata["javascript_origin"]].compact
|
96
|
-
@authorization_uri = fdata[:auth_uri] || fdata["auth_uri"]
|
97
|
-
@authorization_uri ||= fdata[:authorization_uri]
|
98
|
-
@token_credential_uri = fdata[:token_uri] || fdata["token_uri"]
|
99
|
-
@token_credential_uri ||= fdata[:token_credential_uri]
|
100
|
-
|
101
|
-
# Associated token info
|
102
|
-
@access_token = fdata[:access_token] || fdata["access_token"]
|
103
|
-
@refresh_token = fdata[:refresh_token] || fdata["refresh_token"]
|
104
|
-
@id_token = fdata[:id_token] || fdata["id_token"]
|
105
|
-
@expires_in = fdata[:expires_in] || fdata["expires_in"]
|
106
|
-
@expires_at = fdata[:expires_at] || fdata["expires_at"]
|
107
|
-
@issued_at = fdata[:issued_at] || fdata["issued_at"]
|
108
|
-
end
|
109
|
-
|
110
|
-
attr_reader(
|
111
|
-
:flow, :client_id, :client_secret, :redirect_uris, :javascript_origins,
|
112
|
-
:authorization_uri, :token_credential_uri, :access_token,
|
113
|
-
:refresh_token, :id_token, :expires_in, :expires_at, :issued_at
|
114
|
-
)
|
115
|
-
|
116
|
-
##
|
117
|
-
# Serialize back to the original JSON form
|
118
|
-
#
|
119
|
-
# @return [String]
|
120
|
-
# JSON
|
121
|
-
def to_json
|
122
|
-
return Json.dump(to_hash)
|
123
|
-
end
|
124
|
-
|
125
|
-
def to_hash
|
126
|
-
{
|
127
|
-
self.flow => ({
|
128
|
-
'client_id' => self.client_id,
|
129
|
-
'client_secret' => self.client_secret,
|
130
|
-
'redirect_uris' => self.redirect_uris,
|
131
|
-
'javascript_origins' => self.javascript_origins,
|
132
|
-
'auth_uri' => self.authorization_uri,
|
133
|
-
'token_uri' => self.token_credential_uri,
|
134
|
-
'access_token' => self.access_token,
|
135
|
-
'refresh_token' => self.refresh_token,
|
136
|
-
'id_token' => self.id_token,
|
137
|
-
'expires_in' => self.expires_in,
|
138
|
-
'expires_at' => self.expires_at,
|
139
|
-
'issued_at' => self.issued_at
|
140
|
-
}).inject({}) do |accu, (k, v)|
|
141
|
-
# Prunes empty values from JSON output.
|
142
|
-
unless v == nil || (v.respond_to?(:empty?) && v.empty?)
|
143
|
-
accu[k] = v
|
144
|
-
end
|
145
|
-
accu
|
146
|
-
end
|
147
|
-
}
|
148
|
-
end
|
149
|
-
|
150
|
-
def to_authorization
|
151
|
-
# NOTE: Do not rely on this default value, as it may change
|
152
|
-
new_authorization = Signet::OAuth2::Client.new
|
153
|
-
new_authorization.client_id = self.client_id
|
154
|
-
new_authorization.client_secret = self.client_secret
|
155
|
-
new_authorization.authorization_uri = (
|
156
|
-
self.authorization_uri ||
|
157
|
-
'https://accounts.google.com/o/oauth2/auth'
|
158
|
-
)
|
159
|
-
new_authorization.token_credential_uri = (
|
160
|
-
self.token_credential_uri ||
|
161
|
-
'https://accounts.google.com/o/oauth2/token'
|
162
|
-
)
|
163
|
-
new_authorization.redirect_uri = self.redirect_uris.first
|
164
|
-
|
165
|
-
# These are supported, but unlikely.
|
166
|
-
new_authorization.access_token = self.access_token
|
167
|
-
new_authorization.refresh_token = self.refresh_token
|
168
|
-
new_authorization.id_token = self.id_token
|
169
|
-
new_authorization.expires_in = self.expires_in
|
170
|
-
new_authorization.issued_at = self.issued_at if self.issued_at
|
171
|
-
new_authorization.expires_at = self.expires_at if self.expires_at
|
172
|
-
return new_authorization
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|