work_auth_client 0.1.0 → 0.2.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 +20 -26
- data/lib/work_auth_client/version.rb +1 -1
- data/lib/work_auth_client.rb +7 -2
- 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: 524a9d3937c9f581e9aaea0bf829af65dd995294daf303badfcd8f50b4e8ab66
|
4
|
+
data.tar.gz: 49ea2ae9c01c154224efadcc08b3fc06a1a8c37ee0ed4bf72e58ff5e9ca2a7bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7872043228ef31eb2481d2cd0a32b177b48a75eed45e409921a711aef6989aa330aeb123f8a3bc62daabbc8fac6d99185709ac02250fc679399fe25c4475737a
|
7
|
+
data.tar.gz: 8b82247fee9ff89c2161eb246aeec626db2327ebca27aba7999cc496bad00d50fd326f09fc3022688a2f41ab85b9839062e61ae85502ee360d2818db93438ece
|
data/README.md
CHANGED
@@ -1,35 +1,29 @@
|
|
1
|
-
#
|
1
|
+
# README
|
2
2
|
|
3
|
-
|
3
|
+
Install
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
5
|
+
```rb
|
12
6
|
gem 'work_auth_client'
|
13
7
|
```
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
9
|
+
Create and configure a new client:
|
20
10
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
11
|
+
```rb
|
12
|
+
work_auth_client = new WorkAuthClient::Client
|
13
|
+
work_auth_client.host = 'https://work-auth-server.com'
|
14
|
+
```
|
30
15
|
|
31
|
-
|
16
|
+
Generate an access token for your application:
|
32
17
|
|
33
|
-
|
18
|
+
```rb
|
19
|
+
req = new WorkAuthClient::ClientCredentialsRequest.new(
|
20
|
+
client_id: 'your-client-id',
|
21
|
+
client_secret: 'your-client-secret',
|
22
|
+
)
|
34
23
|
|
35
|
-
|
24
|
+
resp = work_auth_client.access_token(req)
|
25
|
+
|
26
|
+
if resp.status == 'success'
|
27
|
+
access_token = resp.body.access_token
|
28
|
+
end
|
29
|
+
```
|
data/lib/work_auth_client.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'ostruct'
|
1
2
|
require 'rest-client'
|
2
3
|
require 'work_auth_client/version'
|
3
4
|
|
@@ -22,10 +23,12 @@ module WorkAuthClient
|
|
22
23
|
raise ArgumentError
|
23
24
|
end
|
24
25
|
|
25
|
-
RestClient.post("#{self.host}/access_token", request.as_json, {
|
26
|
+
resp = RestClient.post("#{self.host}/access_token", request.as_json, {
|
26
27
|
content_type: :json,
|
27
28
|
accept: :json
|
28
29
|
})
|
30
|
+
|
31
|
+
OpenStruct.new(resp)
|
29
32
|
end
|
30
33
|
|
31
34
|
# `verification` makes a call to the authorization server in order to get
|
@@ -37,10 +40,12 @@ module WorkAuthClient
|
|
37
40
|
raise ArgumentError
|
38
41
|
end
|
39
42
|
|
40
|
-
RestClient.post("#{self.host}/access_token", request.as_json, {
|
43
|
+
resp = RestClient.post("#{self.host}/access_token", request.as_json, {
|
41
44
|
content_type: :json,
|
42
45
|
accept: :json
|
43
46
|
})
|
47
|
+
|
48
|
+
OpenStruct.new(resp)
|
44
49
|
end
|
45
50
|
|
46
51
|
private
|