faraday-panoptes 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
  SHA1:
3
- metadata.gz: f9b626bfae3343ec615dfd0dfc13a024655d2635
4
- data.tar.gz: 8ef9c0f1c59c4aaaeb88e0609ff89295b4c621b0
3
+ metadata.gz: 6feed8139403106b15ec1bc8fa20e5e294ca922e
4
+ data.tar.gz: 34b7a32ad0b28af669a02623bfd671555a9ab6ea
5
5
  SHA512:
6
- metadata.gz: 4de3a792e8e88f01feee12262538759732053b02173b9227886e87f1e2937a293b894286362fa16d86e97d4e99884bb49cbb87d9385e2169e9dd0ba8dd1396a3
7
- data.tar.gz: cc29dc5309c8806b177b3136f7466ccccb3a30b87978ee4ed7855427a83c558b10a3b18eb7b38a8c4e90b3b7ed12679d9820fbf87be67516df8bf2e05839f101
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Faraday
2
2
  module Panoptes
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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.1.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: 2015-11-26 00:00:00.000000000 Z
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