work_auth_client 0.2.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 524a9d3937c9f581e9aaea0bf829af65dd995294daf303badfcd8f50b4e8ab66
4
- data.tar.gz: 49ea2ae9c01c154224efadcc08b3fc06a1a8c37ee0ed4bf72e58ff5e9ca2a7bc
3
+ metadata.gz: 142e3aa3ef5623b08d9704b95f2f5e3f129516c51bfda99a166322ed516105fd
4
+ data.tar.gz: 8937f660c799bc906c7e2bb7a5af938d39ed0272b141fe3def8bbc48f3958a46
5
5
  SHA512:
6
- metadata.gz: 7872043228ef31eb2481d2cd0a32b177b48a75eed45e409921a711aef6989aa330aeb123f8a3bc62daabbc8fac6d99185709ac02250fc679399fe25c4475737a
7
- data.tar.gz: 8b82247fee9ff89c2161eb246aeec626db2327ebca27aba7999cc496bad00d50fd326f09fc3022688a2f41ab85b9839062e61ae85502ee360d2818db93438ece
6
+ metadata.gz: 6ec99cfe2f07e3e478fdd69f2b280a945653b7b2471451fe697a39bce0121b6e64f7253ccd6b0c189dd2313bd8f9d5758f54d4ef5fb0a3c71160bb995e6607bf
7
+ data.tar.gz: 186ada0ae988edece6c48d35c7ad98d97f41865056f80b99069f671c6c8a5a5ed40884f312c0630da4b91cb96ed2fe48e262d5183e0d3de547f9aae2a9960293
data/README.md CHANGED
@@ -26,4 +26,26 @@ resp = work_auth_client.access_token(req)
26
26
  if resp.status == 'success'
27
27
  access_token = resp.body.access_token
28
28
  end
29
+ ```
30
+
31
+ Generate an access token for a user:
32
+
33
+ ```rb
34
+ req = new WorkAuthClient::PasswordRequest.new(
35
+ client_id: 'your-client-id',
36
+ client_secret: 'your-client-secret',
37
+ username: 'andy',
38
+ password: '123456'
39
+ )
40
+
41
+ resp = work_auth_client.access_token(req)
42
+
43
+ if resp.status == 'success'
44
+ access_token = resp.body.access_token
45
+ end
46
+ ```
47
+
48
+ Verify a token:
49
+
50
+ ```
29
51
  ```
@@ -36,11 +36,11 @@ module WorkAuthClient
36
36
  def verification(request)
37
37
  validate_host
38
38
 
39
- if !request.is_a?(ClientCredentialsRequest) || !request.is_a?(PasswordRequest)
39
+ if !request.is_a?(VerificationRequest)
40
40
  raise ArgumentError
41
41
  end
42
42
 
43
- resp = RestClient.post("#{self.host}/access_token", request.as_json, {
43
+ resp = RestClient.post("#{self.host}/verification", request.as_json, {
44
44
  content_type: :json,
45
45
  accept: :json
46
46
  })
@@ -96,5 +96,16 @@ module WorkAuthClient
96
96
  end
97
97
 
98
98
  class VerificationRequest
99
+ attr_accessor :access_token
100
+
101
+ def initialize(access_token:)
102
+ self.access_token = access_token
103
+ end
104
+
105
+ def as_json
106
+ {
107
+ access_token: self.access_token
108
+ }
109
+ end
99
110
  end
100
111
  end
@@ -1,3 +1,3 @@
1
1
  module WorkAuthClient
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work_auth_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Sinner