Skip to content

Commit

Permalink
Merge pull request #42 from iron-io/jwt
Browse files Browse the repository at this point in the history
Added jwt tokens.
  • Loading branch information
Reed Allman committed Oct 26, 2015
2 parents d397436 + 46a60bb commit b9f0634
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/iron_worker/api_client.rb
Expand Up @@ -14,19 +14,23 @@ def initialize(options = {})
:user_agent => IronWorker.full_version
}

super('iron', 'worker', options, default_options, [:project_id, :token, :api_version])
super('iron', 'worker', options, default_options, [:project_id, :token, :jwt, :api_version])

IronCore::Logger.debug 'IronWorker', "nhp.proxy: #{rest.wrapper.http.proxy_uri}" if defined? Net::HTTP::Persistent
IronCore::Logger.debug 'IronWorker', "RestClient.proxy: #{RestClient.proxy}" if defined? RestClient
IronCore::Logger.debug 'IronWorker', "InternalClient.proxy: #{Rest::InternalClient.proxy}" if defined? Rest::InternalClient

IronCore::Logger.error 'IronWorker', "Token is not set", IronCore::Error if @token.nil?
IronCore::Logger.error 'IronWorker', "Token is not set", IronCore::Error if @token.nil? && @jwt.nil?

check_id(@project_id, 'project_id')
end

def headers
super.merge({'Authorization' => "OAuth #{@token}"})
if !@jwt.nil?
super.merge({'Authorization' => "JWT #{@jwt}"})
else
super.merge({'Authorization' => "OAuth #{@token}"})
end
end

def base_url
Expand Down
4 changes: 4 additions & 0 deletions lib/iron_worker/client.rb
Expand Up @@ -41,6 +41,10 @@ def token
@api.token
end

def jwt
@api.jwt
end

def project_id
@api.project_id
end
Expand Down

0 comments on commit b9f0634

Please sign in to comment.