googleauth 0.14.0 → 1.3.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 +11 -0
- data/CHANGELOG.md +72 -10
- data/README.md +48 -13
- data/SECURITY.md +7 -0
- data/lib/googleauth/application_default.rb +10 -25
- data/lib/googleauth/client_id.rb +10 -25
- data/lib/googleauth/compute_engine.rb +16 -30
- data/lib/googleauth/credentials.rb +178 -74
- data/lib/googleauth/credentials_loader.rb +23 -44
- data/lib/googleauth/default_credentials.rb +10 -25
- data/lib/googleauth/iam.rb +11 -26
- data/lib/googleauth/id_tokens/errors.rb +9 -23
- data/lib/googleauth/id_tokens/key_sources.rb +26 -38
- data/lib/googleauth/id_tokens/verifier.rb +16 -32
- data/lib/googleauth/id_tokens.rb +9 -23
- data/lib/googleauth/json_key_reader.rb +10 -25
- data/lib/googleauth/scope_util.rb +11 -26
- data/lib/googleauth/service_account.rb +60 -59
- data/lib/googleauth/signet.rb +22 -28
- data/lib/googleauth/stores/file_token_store.rb +11 -25
- data/lib/googleauth/stores/redis_token_store.rb +11 -25
- data/lib/googleauth/token_store.rb +10 -25
- data/lib/googleauth/user_authorizer.rb +10 -25
- data/lib/googleauth/user_refresh.rb +15 -27
- data/lib/googleauth/version.rb +11 -26
- data/lib/googleauth/web_user_authorizer.rb +14 -32
- data/lib/googleauth.rb +10 -25
- metadata +26 -97
- data/.github/CODEOWNERS +0 -7
- data/.github/CONTRIBUTING.md +0 -74
- 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/.gitignore +0 -36
- data/.kokoro/build.bat +0 -16
- data/.kokoro/build.sh +0 -4
- data/.kokoro/continuous/common.cfg +0 -24
- 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 -19
- data/Gemfile +0 -30
- data/Rakefile +0 -132
- data/googleauth.gemspec +0 -38
- data/integration/helper.rb +0 -31
- data/integration/id_tokens/key_source_test.rb +0 -74
- data/rakelib/devsite_builder.rb +0 -45
- data/rakelib/link_checker.rb +0 -64
- data/rakelib/repo_metadata.rb +0 -59
- data/spec/googleauth/apply_auth_examples.rb +0 -171
- data/spec/googleauth/client_id_spec.rb +0 -160
- data/spec/googleauth/compute_engine_spec.rb +0 -160
- data/spec/googleauth/credentials_spec.rb +0 -478
- data/spec/googleauth/get_application_default_spec.rb +0 -286
- data/spec/googleauth/iam_spec.rb +0 -80
- data/spec/googleauth/scope_util_spec.rb +0 -77
- data/spec/googleauth/service_account_spec.rb +0 -489
- data/spec/googleauth/signet_spec.rb +0 -142
- data/spec/googleauth/stores/file_token_store_spec.rb +0 -57
- data/spec/googleauth/stores/redis_token_store_spec.rb +0 -50
- data/spec/googleauth/stores/store_examples.rb +0 -58
- data/spec/googleauth/user_authorizer_spec.rb +0 -343
- data/spec/googleauth/user_refresh_spec.rb +0 -359
- data/spec/googleauth/web_user_authorizer_spec.rb +0 -172
- data/spec/spec_helper.rb +0 -92
- data/test/helper.rb +0 -33
- data/test/id_tokens/key_sources_test.rb +0 -240
- data/test/id_tokens/verifier_test.rb +0 -269
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bc48c47d78d7ec955a2a5557fc8f1cff502a28dd1e18c5af3fc566be5743171
|
4
|
+
data.tar.gz: 220a8fed81a73d5bc93a2fca2951a749b9469cb769a198cf13564ad7f714ac90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73f52ffce21a05e15102b54aabbcb3cb199d32e9caf318b125b48b6caeddc01f77c3de4ea09513b0b1e9e503c912e55adf5864b4295b86af0620aa0c7df25df4
|
7
|
+
data.tar.gz: 7ec107faa35d72aa1fd8e79b86b30df9acf061ce86ac52641bc12b69391f0b4f2adde8021b908327e379dee65c1e2ed7ed1b203e629ca1f4d25a988e80c31eb2
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,77 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.3.0 (2022-10-18)
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* Use OpenSSL 3.0 compatible interfaces for IDTokens ([#397](https://github.com/googleapis/google-auth-library-ruby/issues/397))
|
8
|
+
|
9
|
+
### 1.2.0 (2022-06-23)
|
10
|
+
|
11
|
+
* Updated minimum Ruby version to 2.6
|
12
|
+
|
13
|
+
### 1.1.3 (2022-04-20)
|
14
|
+
|
15
|
+
#### Documentation
|
16
|
+
|
17
|
+
* Add README instructions for 3-Legged OAuth with a service account
|
18
|
+
|
19
|
+
### 1.1.2 (2022-02-22)
|
20
|
+
|
21
|
+
#### Bug Fixes
|
22
|
+
|
23
|
+
* Support Faraday 2
|
24
|
+
|
25
|
+
### 1.1.1 (2022-02-14)
|
26
|
+
|
27
|
+
#### Bug Fixes
|
28
|
+
|
29
|
+
* add quota_project to user refresh credentials
|
30
|
+
|
31
|
+
### 1.1.0 (2021-10-24)
|
32
|
+
|
33
|
+
#### Features
|
34
|
+
|
35
|
+
* Support short-lived tokens in Credentials
|
36
|
+
|
37
|
+
### 1.0.0 (2021-09-27)
|
38
|
+
|
39
|
+
Bumped version to 1.0.0. Releases from this point will follow semver.
|
40
|
+
|
41
|
+
* Allow dependency on future 1.x versions of signet
|
42
|
+
* Prevented gcloud from authenticating on the console when getting the gcloud project
|
43
|
+
|
44
|
+
### 0.17.1 (2021-09-01)
|
45
|
+
|
46
|
+
* Updates to gem metadata
|
47
|
+
|
48
|
+
### 0.17.0 (2021-07-30)
|
49
|
+
|
50
|
+
* Allow scopes to be self-signed into jwts
|
51
|
+
|
52
|
+
### 0.16.2 (2021-04-28)
|
53
|
+
|
54
|
+
* Stop attempting to get the project from gcloud when applying self-signed JWTs
|
55
|
+
|
56
|
+
### 0.16.1 (2021-04-01)
|
57
|
+
|
58
|
+
* Accept application/text content-type for plain idtoken response
|
59
|
+
|
60
|
+
### 0.16.0 (2021-03-04)
|
61
|
+
|
62
|
+
* Drop support for Ruby 2.4 and add support for Ruby 3.0
|
63
|
+
|
64
|
+
### 0.15.1 (2021-02-08)
|
65
|
+
|
66
|
+
* Fix crash when using a client credential without any paths or env_vars set
|
67
|
+
|
68
|
+
### 0.15.0 (2021-01-26)
|
69
|
+
|
70
|
+
* Credential parameters inherit from superclasses
|
71
|
+
* Service accounts apply a self-signed JWT if scopes are marked as default
|
72
|
+
* Retry fetch_access_token when GCE metadata server returns unexpected errors
|
73
|
+
* Support correct service account and user refresh behavior for custom credential env variables
|
74
|
+
|
3
75
|
### 0.14.0 / 2020-10-09
|
4
76
|
|
5
77
|
* Honor GCE_METADATA_HOST environment variable
|
@@ -108,7 +180,6 @@ Note: This release now requires Ruby 2.4 or later
|
|
108
180
|
|
109
181
|
* Change header name emitted by `Client#apply` from "Authorization" to "authorization" ([@murgatroid99][])
|
110
182
|
* Fix ADC not working on some windows machines ([@vsubramani][])
|
111
|
-
[#55](https://github.com/google/google-auth-library-ruby/issues/55)
|
112
183
|
|
113
184
|
### 0.5.0 / 2015-10-12
|
114
185
|
|
@@ -118,19 +189,10 @@ Note: This release now requires Ruby 2.4 or later
|
|
118
189
|
### 0.4.2 / 2015-08-05
|
119
190
|
|
120
191
|
* Updated UserRefreshCredentials hash to use string keys ([@haabaato][])
|
121
|
-
[#36](https://github.com/google/google-auth-library-ruby/issues/36)
|
122
|
-
|
123
192
|
* Add support for a system default credentials file. ([@mr-salty][])
|
124
|
-
[#33](https://github.com/google/google-auth-library-ruby/issues/33)
|
125
|
-
|
126
193
|
* Fix bug when loading credentials from ENV ([@dwilkie][])
|
127
|
-
[#31](https://github.com/google/google-auth-library-ruby/issues/31)
|
128
|
-
|
129
194
|
* Relax the constraint of dependent version of multi_json ([@igrep][])
|
130
|
-
[#30](https://github.com/google/google-auth-library-ruby/issues/30)
|
131
|
-
|
132
195
|
* Enables passing credentials via environment variables. ([@haabaato][])
|
133
|
-
[#27](https://github.com/google/google-auth-library-ruby/issues/27)
|
134
196
|
|
135
197
|
### 0.4.1 / 2015-04-25
|
136
198
|
|
data/README.md
CHANGED
@@ -14,11 +14,6 @@
|
|
14
14
|
This is Google's officially supported ruby client library for using OAuth 2.0
|
15
15
|
authorization and authentication with Google APIs.
|
16
16
|
|
17
|
-
## Alpha
|
18
|
-
|
19
|
-
This library is in Alpha. We will make an effort to support the library, but
|
20
|
-
we reserve the right to make incompatible changes when necessary.
|
21
|
-
|
22
17
|
## Install
|
23
18
|
|
24
19
|
Be sure `https://rubygems.org/` is in your gem sources.
|
@@ -116,6 +111,7 @@ token_store = Google::Auth::Stores::FileTokenStore.new(
|
|
116
111
|
:file => '/path/to/tokens.yaml')
|
117
112
|
authorizer = Google::Auth::UserAuthorizer.new(client_id, scope, token_store)
|
118
113
|
|
114
|
+
user_id = ENV['USER']
|
119
115
|
credentials = authorizer.get_credentials(user_id)
|
120
116
|
if credentials.nil?
|
121
117
|
url = authorizer.get_authorization_url(base_url: OOB_URI )
|
@@ -140,6 +136,43 @@ authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
|
|
140
136
|
authorizer.fetch_access_token!
|
141
137
|
```
|
142
138
|
|
139
|
+
You can also use a JSON keyfile by setting the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
|
140
|
+
|
141
|
+
```bash
|
142
|
+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service_account_json_key.json
|
143
|
+
```
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
require 'googleauth'
|
147
|
+
require 'google/apis/drive_v3'
|
148
|
+
|
149
|
+
Drive = ::Google::Apis::DriveV3
|
150
|
+
drive = Drive::DriveService.new
|
151
|
+
|
152
|
+
scope = 'https://www.googleapis.com/auth/drive'
|
153
|
+
|
154
|
+
authorizer = Google::Auth::ServiceAccountCredentials.from_env(scope: scope)
|
155
|
+
drive.authorization = authorizer
|
156
|
+
|
157
|
+
list_files = drive.list_files()
|
158
|
+
```
|
159
|
+
|
160
|
+
### 3-Legged OAuth with a Service Account
|
161
|
+
|
162
|
+
This is similar to regular service account authorization (see [this answer](https://support.google.com/a/answer/2538798?hl=en) for more details on the differences), but you'll need to indicate which user your service account is impersonating by manually updating the `sub` field.
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
scope = 'https://www.googleapis.com/auth/androidpublisher'
|
166
|
+
|
167
|
+
authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
|
168
|
+
json_key_io: File.open('/path/to/service_account_json_key.json'),
|
169
|
+
scope: scope
|
170
|
+
)
|
171
|
+
authorizer.update!(sub: "email-to-impersonate@your-domain.com")
|
172
|
+
|
173
|
+
authorizer.fetch_access_token!
|
174
|
+
```
|
175
|
+
|
143
176
|
### Example (Environment Variables)
|
144
177
|
|
145
178
|
```bash
|
@@ -182,17 +215,19 @@ Custom storage implementations can also be used. See
|
|
182
215
|
|
183
216
|
## Supported Ruby Versions
|
184
217
|
|
185
|
-
This library
|
218
|
+
This library is supported on Ruby 2.6+.
|
186
219
|
|
187
|
-
|
188
|
-
|
189
|
-
maintenance
|
190
|
-
|
220
|
+
Google provides official support for Ruby versions that are actively supported
|
221
|
+
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
222
|
+
in security maintenance, and not end of life. Older versions of Ruby _may_
|
223
|
+
still work, but are unsupported and not recommended. See
|
224
|
+
https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby
|
225
|
+
support schedule.
|
191
226
|
|
192
227
|
## License
|
193
228
|
|
194
229
|
This library is licensed under Apache 2.0. Full license text is
|
195
|
-
available in [
|
230
|
+
available in [LICENSE][license].
|
196
231
|
|
197
232
|
## Contributing
|
198
233
|
|
@@ -207,5 +242,5 @@ hesitate to
|
|
207
242
|
about the client or APIs on [StackOverflow](http://stackoverflow.com).
|
208
243
|
|
209
244
|
[application default credentials]: https://developers.google.com/accounts/docs/application-default-credentials
|
210
|
-
[contributing]: https://github.com/googleapis/google-auth-library-ruby/tree/
|
211
|
-
[
|
245
|
+
[contributing]: https://github.com/googleapis/google-auth-library-ruby/tree/main/.github/CONTRIBUTING.md
|
246
|
+
[license]: https://github.com/googleapis/google-auth-library-ruby/tree/main/LICENSE
|
data/SECURITY.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
To report a security issue, please use [g.co/vulnz](https://g.co/vulnz).
|
4
|
+
|
5
|
+
The Google Security Team will respond within 5 working days of your report on g.co/vulnz.
|
6
|
+
|
7
|
+
We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue.
|
@@ -1,31 +1,16 @@
|
|
1
|
-
# Copyright 2015
|
2
|
-
# All rights reserved.
|
1
|
+
# Copyright 2015 Google, Inc.
|
3
2
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
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
|
7
6
|
#
|
8
|
-
#
|
9
|
-
# notice, this list of conditions and the following disclaimer.
|
10
|
-
# * Redistributions in binary form must reproduce the above
|
11
|
-
# copyright notice, this list of conditions and the following disclaimer
|
12
|
-
# in the documentation and/or other materials provided with the
|
13
|
-
# distribution.
|
14
|
-
# * Neither the name of Google Inc. nor the names of its
|
15
|
-
# contributors may be used to endorse or promote products derived from
|
16
|
-
# this software without specific prior written permission.
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
8
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
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.
|
29
14
|
|
30
15
|
require "googleauth/compute_engine"
|
31
16
|
require "googleauth/default_credentials"
|
data/lib/googleauth/client_id.rb
CHANGED
@@ -1,31 +1,16 @@
|
|
1
|
-
# Copyright 2014
|
2
|
-
# All rights reserved.
|
1
|
+
# Copyright 2014 Google, Inc.
|
3
2
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
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
|
7
6
|
#
|
8
|
-
#
|
9
|
-
# notice, this list of conditions and the following disclaimer.
|
10
|
-
# * Redistributions in binary form must reproduce the above
|
11
|
-
# copyright notice, this list of conditions and the following disclaimer
|
12
|
-
# in the documentation and/or other materials provided with the
|
13
|
-
# distribution.
|
14
|
-
# * Neither the name of Google Inc. nor the names of its
|
15
|
-
# contributors may be used to endorse or promote products derived from
|
16
|
-
# this software without specific prior written permission.
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
8
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
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.
|
29
14
|
|
30
15
|
require "multi_json"
|
31
16
|
require "googleauth/credentials_loader"
|
@@ -1,31 +1,16 @@
|
|
1
|
-
# Copyright 2015
|
2
|
-
# All rights reserved.
|
1
|
+
# Copyright 2015 Google, Inc.
|
3
2
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
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
|
7
6
|
#
|
8
|
-
#
|
9
|
-
# notice, this list of conditions and the following disclaimer.
|
10
|
-
# * Redistributions in binary form must reproduce the above
|
11
|
-
# copyright notice, this list of conditions and the following disclaimer
|
12
|
-
# in the documentation and/or other materials provided with the
|
13
|
-
# distribution.
|
14
|
-
# * Neither the name of Google Inc. nor the names of its
|
15
|
-
# contributors may be used to endorse or promote products derived from
|
16
|
-
# this software without specific prior written permission.
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
8
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
24
|
-
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
25
|
-
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
26
|
-
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
27
|
-
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
28
|
-
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
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.
|
29
14
|
|
30
15
|
require "faraday"
|
31
16
|
require "googleauth/signet"
|
@@ -108,21 +93,22 @@ module Google
|
|
108
93
|
uri = target_audience ? GCECredentials.compute_id_token_uri : GCECredentials.compute_auth_token_uri
|
109
94
|
query = target_audience ? { "audience" => target_audience, "format" => "full" } : {}
|
110
95
|
query[:scopes] = Array(scope).join "," if scope
|
111
|
-
|
112
|
-
resp = c.get uri, query, headers
|
96
|
+
resp = c.get uri, query, "Metadata-Flavor" => "Google"
|
113
97
|
case resp.status
|
114
98
|
when 200
|
115
99
|
content_type = resp.headers["content-type"]
|
116
|
-
if
|
100
|
+
if ["text/html", "application/text"].include? content_type
|
117
101
|
{ (target_audience ? "id_token" : "access_token") => resp.body }
|
118
102
|
else
|
119
103
|
Signet::OAuth2.parse_credentials resp.body, content_type
|
120
104
|
end
|
105
|
+
when 403, 500
|
106
|
+
msg = "Unexpected error code #{resp.status} #{UNEXPECTED_ERROR_SUFFIX}"
|
107
|
+
raise Signet::UnexpectedStatusError, msg
|
121
108
|
when 404
|
122
109
|
raise Signet::AuthorizationError, NO_METADATA_SERVER_ERROR
|
123
110
|
else
|
124
|
-
msg = "Unexpected error code #{resp.status}"
|
125
|
-
"#{UNEXPECTED_ERROR_SUFFIX}"
|
111
|
+
msg = "Unexpected error code #{resp.status} #{UNEXPECTED_ERROR_SUFFIX}"
|
126
112
|
raise Signet::AuthorizationError, msg
|
127
113
|
end
|
128
114
|
end
|