Permalink
Browse files

Merge branch 'token' into dev

  • Loading branch information...
2 parents 70b2d52 + 3d7b0ba commit 6e05936cd0c10d6fc1d7c7b42e211ae41f83faed @mutle committed Dec 11, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/zendesk2/client.rb
View
@@ -89,11 +89,15 @@ def initialize(options={})
password = options[:password] || Zendesk2.defaults[:password]
@token = options[:token]
- raise "Missing required options: [:username, :password]" unless @username && password
+ raise "Missing required options: [:username, :password]" unless @username && (password || @token)
@connection = Faraday.new({url: @url}.merge(connection_options)) do |builder|
# response
- builder.use Faraday::Request::BasicAuthentication, @username, password
+ if @token
+ builder.use Faraday::Request::BasicAuthentication, "#{@username}/token", @token
+ else
+ builder.use Faraday::Request::BasicAuthentication, @username, password
+ end
builder.use Faraday::Response::RaiseError
builder.response :json

0 comments on commit 6e05936

Please sign in to comment.