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 +4 -4
- data/README.md +22 -0
- data/lib/work_auth_client.rb +13 -2
- data/lib/work_auth_client/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: 142e3aa3ef5623b08d9704b95f2f5e3f129516c51bfda99a166322ed516105fd
|
4
|
+
data.tar.gz: 8937f660c799bc906c7e2bb7a5af938d39ed0272b141fe3def8bbc48f3958a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
```
|
data/lib/work_auth_client.rb
CHANGED
@@ -36,11 +36,11 @@ module WorkAuthClient
|
|
36
36
|
def verification(request)
|
37
37
|
validate_host
|
38
38
|
|
39
|
-
if !request.is_a?(
|
39
|
+
if !request.is_a?(VerificationRequest)
|
40
40
|
raise ArgumentError
|
41
41
|
end
|
42
42
|
|
43
|
-
resp = RestClient.post("#{self.host}/
|
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
|