multiwoven-integrations 0.43.6 → 0.43.7
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b171a1cc51b28558fb343520c6a867e9a2b2aa25c087ba400421b5a2b3da7590
|
|
4
|
+
data.tar.gz: 3ce2cd2a913e5b938d8c6580272db97669019b0b23f91d75d9b2722dfc6d9746
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3dd73536846bd3620ded680aaf86c33019b693420974bbe65511ae4ee3f91b9ba91a3d75fe9d660db7ae4092fccaef7b60ed690de789b8e394850be69aa67dc
|
|
7
|
+
data.tar.gz: 2a187270474321f4d52e657f3bb9d871e418bae877a8fa4d6c6337abb657bb0f818c1d2d7197cb9c0e6e253211533903a34518c27c545f29b18a654fdffa28f9
|
data/CHANGELOG.md
CHANGED
|
@@ -21,6 +21,8 @@ module Multiwoven
|
|
|
21
21
|
# should benefit from the cache. Without it, a fresh token is fetched every
|
|
22
22
|
# call — safe but wasteful.
|
|
23
23
|
module OauthClientCredentials
|
|
24
|
+
class OauthTokenRequestError < RuntimeError; end
|
|
25
|
+
|
|
24
26
|
AUTH_TYPE_OAUTH_CLIENT_CREDENTIALS = "oauth_client_credentials"
|
|
25
27
|
AUTH_TYPE_PRIVATE_KEY_JWT = "oauth_private_key_jwt"
|
|
26
28
|
OAUTH_AUTH_TYPES = [AUTH_TYPE_OAUTH_CLIENT_CREDENTIALS, AUTH_TYPE_PRIVATE_KEY_JWT].freeze
|
|
@@ -33,6 +35,7 @@ module Multiwoven
|
|
|
33
35
|
# Refresh access tokens this many seconds before their advertised expiry,
|
|
34
36
|
# so a token that expires mid-request doesn't leave the connector.
|
|
35
37
|
TOKEN_EXPIRY_BUFFER_SECONDS = 300
|
|
38
|
+
TRANSIENT_HTTP_STATUSES = %w[408 429].freeze
|
|
36
39
|
|
|
37
40
|
def build_headers(connection_config)
|
|
38
41
|
headers = (connection_config[:headers] || {}).to_h.dup
|
|
@@ -76,7 +79,7 @@ module Multiwoven
|
|
|
76
79
|
else
|
|
77
80
|
post_client_secret_token_request(connection_config)
|
|
78
81
|
end
|
|
79
|
-
|
|
82
|
+
raise_token_request_error(response) unless response.is_a?(Net::HTTPSuccess)
|
|
80
83
|
|
|
81
84
|
body = JSON.parse(response.body)
|
|
82
85
|
access_token = body["access_token"]
|
|
@@ -87,6 +90,17 @@ module Multiwoven
|
|
|
87
90
|
access_token
|
|
88
91
|
end
|
|
89
92
|
|
|
93
|
+
def raise_token_request_error(response)
|
|
94
|
+
message = "OAuth token request failed: #{response.code} #{response.body}"
|
|
95
|
+
raise OauthTokenRequestError, message if rejected_token_request?(response)
|
|
96
|
+
|
|
97
|
+
raise message
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def rejected_token_request?(response)
|
|
101
|
+
response.is_a?(Net::HTTPClientError) && !TRANSIENT_HTTP_STATUSES.include?(response.code)
|
|
102
|
+
end
|
|
103
|
+
|
|
90
104
|
def post_client_secret_token_request(connection_config)
|
|
91
105
|
token_url = connection_config[:token_url]
|
|
92
106
|
client_id = connection_config[:client_id]
|