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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e6bc9ab3e268219006f9a3395a2bbebfc24e7ecb8d506ae42d25fe11db2d87b0
4
- data.tar.gz: 7aba6065db2b0129ce6bff0bfd1d8dde8cf737baa9872f8421f8abd3e5a88527
3
+ metadata.gz: 524a9d3937c9f581e9aaea0bf829af65dd995294daf303badfcd8f50b4e8ab66
4
+ data.tar.gz: 49ea2ae9c01c154224efadcc08b3fc06a1a8c37ee0ed4bf72e58ff5e9ca2a7bc
5
5
  SHA512:
6
- metadata.gz: 966dd675a08393c830d011dba8b31980e0637c54be0627e34be7a30d92b9ce7fe81aafe318df04aa6c8504fe41efc49952bc031ade078b498e17caa93369a125
7
- data.tar.gz: c2f5ff889d003edefdb44b273e7ace4a95cda2b2586fdd1e1098b0c591ffc446501046214a727818cc2fdf07a3b92685070cc9b48cb2a21b3b7e2fd9eb30790d
6
+ metadata.gz: 7872043228ef31eb2481d2cd0a32b177b48a75eed45e409921a711aef6989aa330aeb123f8a3bc62daabbc8fac6d99185709ac02250fc679399fe25c4475737a
7
+ data.tar.gz: 8b82247fee9ff89c2161eb246aeec626db2327ebca27aba7999cc496bad00d50fd326f09fc3022688a2f41ab85b9839062e61ae85502ee360d2818db93438ece
data/README.md CHANGED
@@ -1,35 +1,29 @@
1
- # WorkAuthClient
1
+ # README
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/work_auth_client`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Install
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
9
+ Create and configure a new client:
20
10
 
21
- $ gem install work_auth_client
22
-
23
- ## Usage
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
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
16
+ Generate an access token for your application:
32
17
 
33
- ## Contributing
18
+ ```rb
19
+ req = new WorkAuthClient::ClientCredentialsRequest.new(
20
+ client_id: 'your-client-id',
21
+ client_secret: 'your-client-secret',
22
+ )
34
23
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/work_auth_client.
24
+ resp = work_auth_client.access_token(req)
25
+
26
+ if resp.status == 'success'
27
+ access_token = resp.body.access_token
28
+ end
29
+ ```
@@ -1,3 +1,3 @@
1
1
  module WorkAuthClient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -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
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Sinner