xero-ruby 2.10.1 → 2.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/xero-ruby/api_client.rb +10 -6
- data/lib/xero-ruby/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaa8295ee798049a210f04184b5a9bd47e6c6d06b5f5e7a7197a021ca997cdf0
|
4
|
+
data.tar.gz: 8048f7bc8f95742fbdf1804ed40ea6325c3f87e54d2454cea05f1c444d45558d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e469a609bad593d2a26dfe78a8864c7a9a067b8c2b26ae707a910a6de4c53b8a368daaff62dd3adea72159a7467cc0025d31eba39b728c00829a45329756dc3c
|
7
|
+
data.tar.gz: 01d586c5e99f4ecc8bea4551d44604c09e0bb3890c8756935bc9a6905b8c5b6cf86e4aeef39c2b0d2666e44b1ff5017d6812c809629c9bdc26585fd37d944cc9
|
data/README.md
CHANGED
@@ -110,15 +110,15 @@ A `token_set` is what we call the XeroAPI response that contains data about your
|
|
110
110
|
|
111
111
|
Note that an `access_token` is valid for 30 minutes but a `refresh_token` can be used once in up to a 60 day window. If a refresh_token is used to refresh access you must replace the entire token_set.
|
112
112
|
|
113
|
-
Both the `id_token` & `access_token` are JWT's, and can be decoded
|
113
|
+
Both the `id_token` & `access_token` are JWT's, and can be decoded to see additional metadata described in the Token Helpers section:
|
114
114
|
## Making API calls with a valid token_set
|
115
115
|
After the initial user interaction you can simply setup a xero_client by passing the whole token_set to the client.
|
116
116
|
```ruby
|
117
117
|
xero_client.set_token_set(user.token_set)
|
118
|
-
|
118
|
+
# or set it and refresh in same go
|
119
119
|
xero_client.refresh_token_set(user.token_set)
|
120
120
|
```
|
121
|
-
This sets the access_token on the client,
|
121
|
+
This sets the access_token on the client returns either the existing, or newly refreshed `token_set`. You should save in your database for the next time you need to connect to Xero's AP and repeat the process. Assuming you keep your connection live at least once per 60 days, you can persist infinite API connection assuming the user does not revoke your API access.
|
122
122
|
## Token Helpers
|
123
123
|
```ruby
|
124
124
|
xero_client.token_set
|
data/lib/xero-ruby/api_client.rb
CHANGED
@@ -110,11 +110,11 @@ module XeroRuby
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def decoded_access_token
|
113
|
-
decode_jwt(@config.access_token)
|
113
|
+
decode_jwt(@config.access_token, false)
|
114
114
|
end
|
115
115
|
|
116
116
|
def decoded_id_token
|
117
|
-
decode_jwt(@config.id_token)
|
117
|
+
decode_jwt(@config.id_token, false)
|
118
118
|
end
|
119
119
|
|
120
120
|
def set_token_set(token_set)
|
@@ -166,10 +166,14 @@ module XeroRuby
|
|
166
166
|
return true
|
167
167
|
end
|
168
168
|
|
169
|
-
def decode_jwt(tkn)
|
170
|
-
|
171
|
-
|
172
|
-
|
169
|
+
def decode_jwt(tkn, verify=true)
|
170
|
+
if verify == true
|
171
|
+
jwks_data = JSON.parse(Faraday.get('https://identity.xero.com/.well-known/openid-configuration/jwks').body)
|
172
|
+
jwk_set = JSON::JWK::Set.new(jwks_data)
|
173
|
+
JSON::JWT.decode(tkn, jwk_set)
|
174
|
+
else
|
175
|
+
JSON::JWT.decode(tkn, :skip_verification)
|
176
|
+
end
|
173
177
|
end
|
174
178
|
|
175
179
|
def token_expired?
|
data/lib/xero-ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xero-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.10.
|
4
|
+
version: 2.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xero API Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -995,7 +995,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
995
995
|
- !ruby/object:Gem::Version
|
996
996
|
version: '0'
|
997
997
|
requirements: []
|
998
|
-
rubygems_version: 3.1.
|
998
|
+
rubygems_version: 3.1.2
|
999
999
|
signing_key:
|
1000
1000
|
specification_version: 4
|
1001
1001
|
summary: Xero Accounting API Ruby Gem
|