aptible-auth 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/lib/aptible/auth/client.rb +11 -2
- data/lib/aptible/auth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34caa61e053fc96d4a43bd90c73db5a00776c634
|
4
|
+
data.tar.gz: fef45746c7c7ab4d42be4bf720f0b42c0f192edf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f2d7eb28d29eddd7cf8e5473a3d143fc01ff67c3605f5471a8e34190c3256ddcd22784967001841a95a357d86eff03e144886f32772821536f2fb5b6aa4304e
|
7
|
+
data.tar.gz: 06e82bb7831bbf3b3dfeda977dd3b655a5977986e7de8223567b3b693ea84ad719e84db86697c7e049cf2d82ae2ae9da1668b3178189ec2a096180825f8b71c2
|
data/README.md
CHANGED
@@ -12,9 +12,12 @@ Add the following lines to your application's Gemfile.
|
|
12
12
|
|
13
13
|
gem 'aptible-auth'
|
14
14
|
gem 'oauth2', github: 'fancyremarker/oauth2', branch: 'aptible'
|
15
|
+
gem 'hyperresource', github: 'fancyremarker/hyperresource', branch: 'aptible'
|
15
16
|
|
16
17
|
The forked version of the OAuth2 gem is necessary until [intridea/oauth2#165](https://github.com/intridea/oauth2/pull/165) and [intridea/oauth2#166](https://github.com/intridea/oauth2/pull/166) are merged.
|
17
18
|
|
19
|
+
The forked version of the HyperResource gem is necessary until [gamache/hyperresource#19](https://github.com/gamache/hyperresource/pull/19) is merged.
|
20
|
+
|
18
21
|
And then run `bundle install`.
|
19
22
|
|
20
23
|
## Usage
|
@@ -33,12 +36,11 @@ auth = Aptible::Auth::Client.new(token: token)
|
|
33
36
|
From here, you can interact with the Authorization API however you wish:
|
34
37
|
|
35
38
|
```ruby
|
36
|
-
auth.get
|
37
|
-
auth.clients.count
|
39
|
+
auth.get.clients.count
|
38
40
|
# => 4
|
39
|
-
auth.clients.first.name
|
41
|
+
auth.get.clients.first.name
|
40
42
|
# => "Client 0"
|
41
|
-
client = auth.clients.create(name: 'Dogeclient')
|
43
|
+
client = auth.get.clients.create(name: 'Dogeclient')
|
42
44
|
client.href
|
43
45
|
# => "http://localhost:4000/clients/60765b69-ffd8-4762-b9d2-96354ddb16f9"
|
44
46
|
```
|
data/lib/aptible/auth/client.rb
CHANGED
@@ -9,17 +9,26 @@ module Aptible
|
|
9
9
|
unless options.is_a?(Hash)
|
10
10
|
fail ArgumentError, 'Call Aptible::Auth::Client.new with a Hash'
|
11
11
|
end
|
12
|
-
|
12
|
+
self.token = options[:token]
|
13
13
|
|
14
14
|
options[:root] ||= config.root_url
|
15
15
|
options[:headers] ||= { 'Content-Type' => 'application/json' }
|
16
16
|
options[:headers].merge!(
|
17
|
-
'Authorization' => "Bearer #{
|
17
|
+
'Authorization' => "Bearer #{bearer_token}"
|
18
18
|
) if options[:token]
|
19
19
|
|
20
20
|
super(options)
|
21
21
|
end
|
22
22
|
|
23
|
+
def bearer_token
|
24
|
+
# REVIEW: Should we really allow any token type here?
|
25
|
+
case token
|
26
|
+
when Aptible::Auth::Token then token.access_token
|
27
|
+
when Fridge::AccessToken then token.to_s
|
28
|
+
when String then token
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
23
32
|
def config
|
24
33
|
@config ||= Aptible::Auth.configuration
|
25
34
|
end
|
data/lib/aptible/auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aptible-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Macreery
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_config
|