jbr 3.7.0 → 3.7.2
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/CHANGELOG.md +19 -0
- data/README.md +5 -4
- data/lib/jbr/token.rb +5 -12
- data/lib/jbr/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: e017275cf5a3a41647f3817608327ddf8fa909c2fdf25e1f8c2a43ee1ad3b044
|
|
4
|
+
data.tar.gz: 1d01c835b75bd16cd21b8d4e658644520cc065c0659b1f394f105e02775b8f69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89e55dd309b839918c67d79ee4c761d28cacb3f2c0dba30daa996354b0a22c4436aa52928dbfb7208df62609073157f77e42f7349943f4f58a2910dea1f43f00
|
|
7
|
+
data.tar.gz: 2cd3bf9d534e4fbb349debe3643aad4a62982e5780e27e558214594ffe9d536413bc5e8d837976d832422011b5da9be146bd9998492f6c33d99011274c213ef5
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## [3.7.2] - 2026-08-17
|
|
2
|
+
|
|
3
|
+
- [Change] Jobber's token endpoint answers in prose, so that is all this reads. 3.7.1 kept a
|
|
4
|
+
branch for the OAuth 2 `invalid_grant` in a JSON body, guarded by a rescue for a body that
|
|
5
|
+
would not parse — and every failure body Jobber has ever been seen to send is prose, so the
|
|
6
|
+
rescue was the path and the branch it protected had never once been taken. Both are gone
|
|
7
|
+
|
|
8
|
+
## [3.7.1] - 2026-08-17
|
|
9
|
+
|
|
10
|
+
- [Fix] A refresh token Jobber will not take gives the credentials up, as it always should
|
|
11
|
+
have. Jobber answers that one in prose and with a 401 — `The provided refresh token is not
|
|
12
|
+
valid.` — where this gem only recognised the OAuth 2 `invalid_grant` in a JSON body, so it
|
|
13
|
+
read a dead grant as a bad moment: `invalid_at` was never set, the error escaped to the
|
|
14
|
+
caller, and an app that persists what it is told kept an authentication that could never work
|
|
15
|
+
again and retried it forever
|
|
16
|
+
- [Change] Read the body rather than the status, deliberately. Jobber answers 401 to an app
|
|
17
|
+
whose own client id and secret are wrong just as readily, and giving credentials up over that
|
|
18
|
+
would disconnect every account at once over one misconfigured app
|
|
19
|
+
|
|
1
20
|
## [3.7.0] - 2026-08-17
|
|
2
21
|
|
|
3
22
|
- [New] `store:`, for credentials several processes hold copies of. A queue of workers each
|
data/README.md
CHANGED
|
@@ -67,10 +67,11 @@ Revoke credentials:
|
|
|
67
67
|
oauth.delete
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
Credentials go bad only when Jobber says so
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
Credentials go bad only when Jobber says so of the grant itself — `The provided refresh token
|
|
71
|
+
is not valid.` — which sets `invalid_at` and answers queries with nothing. Anything else that
|
|
72
|
+
goes wrong raises `Jbr::Error` instead: a 500, a rate limit, and the 401 Jobber answers an app
|
|
73
|
+
whose own client id and secret are wrong, which is every account's grant at once rather than
|
|
74
|
+
this one's:
|
|
74
75
|
|
|
75
76
|
```ruby
|
|
76
77
|
oauth.invalid_at # => 2026-08-13 11:02:41, or nil while the credentials are good
|
data/lib/jbr/token.rb
CHANGED
|
@@ -4,8 +4,10 @@ module Jbr
|
|
|
4
4
|
# Where a grant is exchanged.
|
|
5
5
|
URL = 'https://api.getjobber.com/api/oauth/token'
|
|
6
6
|
|
|
7
|
-
# What Jobber
|
|
8
|
-
|
|
7
|
+
# What Jobber says of a grant it will not take, in the prose it answers with. About the
|
|
8
|
+
# token rather than about the app, which is what tells it from the 401 a wrong client id and
|
|
9
|
+
# secret get — and that one is every account at once rather than this one.
|
|
10
|
+
REFUSAL = /refresh token is not valid/
|
|
9
11
|
|
|
10
12
|
# Trade a grant for credentials.
|
|
11
13
|
# @param params [Hash] the grant, and the app making the exchange.
|
|
@@ -14,7 +16,7 @@ module Jbr
|
|
|
14
16
|
# @return [Hash] the tokens, and the moment the access one expires.
|
|
15
17
|
def self.post(params = {})
|
|
16
18
|
response = Net::HTTP.post_form URI(URL), params
|
|
17
|
-
raise Refused, response.body if
|
|
19
|
+
raise Refused, response.body if REFUSAL.match? response.body
|
|
18
20
|
raise Error, response.body unless response.is_a? Net::HTTPSuccess
|
|
19
21
|
|
|
20
22
|
output = JSON.parse response.body
|
|
@@ -22,14 +24,5 @@ module Jbr
|
|
|
22
24
|
expires_at: (Time.now + output.fetch('expires_in', 3600).to_i),
|
|
23
25
|
}
|
|
24
26
|
end
|
|
25
|
-
|
|
26
|
-
def self.refused?(response)
|
|
27
|
-
return false if response.is_a? Net::HTTPSuccess
|
|
28
|
-
|
|
29
|
-
JSON.parse(response.body)['error'] == REFUSAL
|
|
30
|
-
rescue JSON::ParserError
|
|
31
|
-
false
|
|
32
|
-
end
|
|
33
|
-
private_class_method :refused?
|
|
34
27
|
end
|
|
35
28
|
end
|
data/lib/jbr/version.rb
CHANGED