faraday-panoptes 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +2 -0
- data/lib/faraday/panoptes.rb +2 -0
- data/lib/faraday/panoptes/access_token_authentication.rb +30 -0
- data/lib/faraday/panoptes/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6feed8139403106b15ec1bc8fa20e5e294ca922e
|
4
|
+
data.tar.gz: 34b7a32ad0b28af669a02623bfd671555a9ab6ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e343315e2e832c221fbb8439f93ed377bb57b8486e46ca6b7ed850f092394436af7628c8db888eb8582d9b3443f4a78e569c38fc491cf3a87fd29529b2c40ef
|
7
|
+
data.tar.gz: 9a50049435e9884a5f14c85e26278aea48dc641571f2c7c903c8272c4614f441d7fb1331603efababe0272cbad3f1e28fe10ad29e6f070f3b6f26db143f1f4c7
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# 0.2.0
|
2
|
+
|
3
|
+
* Provides Faraday middleware which just sets the OAuth access token in the correct header
|
4
|
+
|
5
|
+
# 0.1.0
|
6
|
+
|
7
|
+
* Initial release.
|
8
|
+
* Provides Faraday middleware which will request access tokens using application key/secret and refresh them when needed.
|
9
|
+
* Provides Faraday middleware which will set correct headers for version 1 of the API.
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ This gem gives you a set of middleware that lets you use the Zooniverse Panoptes
|
|
4
4
|
|
5
5
|
```ruby
|
6
6
|
api_client = Faraday.new(url: "https://panoptes.zooniverse.org") do |faraday|
|
7
|
+
faraday.adapter Faraday.default_adapter # WITHOUT THIS LINE NOTHING WILL HAPPEN
|
8
|
+
|
7
9
|
faraday.request :panoptes_client_credentials, url: 'https://panoptes.zooniverse.org', client_id: 'APPLICATION_ID', client_secret: 'APPLICATION_SECRET'
|
8
10
|
faraday.request :panoptes_api_v1
|
9
11
|
faraday.response :json
|
data/lib/faraday/panoptes.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require "faraday/panoptes/version"
|
2
2
|
require 'faraday/panoptes/api_v1'
|
3
|
+
require 'faraday/panoptes/access_token_authentication'
|
3
4
|
require 'faraday/panoptes/client_credentials_authentication'
|
4
5
|
|
5
6
|
module Faraday
|
6
7
|
module Panoptes
|
7
8
|
Faraday::Request.register_middleware \
|
9
|
+
panoptes_access_token: lambda { AccessTokenAuthentication },
|
8
10
|
panoptes_client_credentials: lambda { ClientCredentialsAuthentication },
|
9
11
|
panoptes_api_v1: lambda { ApiV1 }
|
10
12
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
module Faraday
|
5
|
+
module Panoptes
|
6
|
+
class AccessTokenAuthentication < Faraday::Middleware
|
7
|
+
dependency do
|
8
|
+
require 'json' unless defined?(::JSON)
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(app, url:, access_token:)
|
12
|
+
super(app)
|
13
|
+
@access_token = access_token
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
env[:request_headers]["Authorization"] = authorization_header
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
|
21
|
+
def authorization_header
|
22
|
+
"Bearer #{access_token}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def access_token
|
26
|
+
@access_token
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-panoptes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -104,6 +104,7 @@ extra_rdoc_files: []
|
|
104
104
|
files:
|
105
105
|
- ".gitignore"
|
106
106
|
- ".travis.yml"
|
107
|
+
- CHANGELOG.md
|
107
108
|
- CODE_OF_CONDUCT.md
|
108
109
|
- Gemfile
|
109
110
|
- LICENSE.txt
|
@@ -113,6 +114,7 @@ files:
|
|
113
114
|
- bin/setup
|
114
115
|
- faraday-panoptes.gemspec
|
115
116
|
- lib/faraday/panoptes.rb
|
117
|
+
- lib/faraday/panoptes/access_token_authentication.rb
|
116
118
|
- lib/faraday/panoptes/api_v1.rb
|
117
119
|
- lib/faraday/panoptes/client_credentials_authentication.rb
|
118
120
|
- lib/faraday/panoptes/version.rb
|