Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

Commit

Permalink
Allow custom user-agent and set a useful default
Browse files Browse the repository at this point in the history
  • Loading branch information
dkerwin committed Jan 14, 2015
1 parent d95d32f commit a1c2031
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/gini-api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Client
# @option options [String] :api_uri API URI (https://api.gini.net)
# @option options [String] :api_version API version to use (v1)
# @option options [Logger] :log logger object to use (initialized with STDOUT otherwise)
# @option options [String] :user_agent HTTP User-Agent (gini-api-ruby/VERSION (Faraday vFaraday::VERSION))
#
# @example
# api = Gini::Api::Client.new(
Expand All @@ -42,6 +43,7 @@ def initialize(options = {})
upload_timeout: 90,
processing_timeout: 180,
log: Logger.new(STDOUT),
user_agent: "gini-api-ruby/#{VERSION} (Faraday v#{Faraday::VERSION})"
}.merge(options)

# Ensure mandatory keys are set
Expand Down
1 change: 1 addition & 0 deletions lib/gini-api/oauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def initialize(api, opts)
token_url: '/oauth/token',
max_redirects: 0,
raise_errors: true,
connection_opts: { headers: { user_agent: api.user_agent } }
)

# Verify opts. Prefered authorization methis is auth_code. If no auth_code is present a login from
Expand Down
3 changes: 2 additions & 1 deletion spec/gini-api/oauth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
client_id: 'cid',
client_secret: 'sec',
oauth_site: oauth_site,
oauth_redirect: redirect
oauth_redirect: redirect,
user_agent: 'gini-api-ruby/spec'
)
end

Expand Down

0 comments on commit a1c2031

Please sign in to comment.