From 520d9bd8919a24f9dda427d8c0a164ca96fb7ad9 Mon Sep 17 00:00:00 2001 From: Travis Reeder Date: Mon, 26 Oct 2015 11:33:59 -0700 Subject: [PATCH 1/2] Added jwt tokens. --- lib/iron_worker/api_client.rb | 10 +++++++--- lib/iron_worker/client.rb | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/iron_worker/api_client.rb b/lib/iron_worker/api_client.rb index 2795f1e..5c22b8c 100644 --- a/lib/iron_worker/api_client.rb +++ b/lib/iron_worker/api_client.rb @@ -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 #{@token}"}) + else + super.merge({'Authorization' => "OAuth #{@token}"}) + end end def base_url diff --git a/lib/iron_worker/client.rb b/lib/iron_worker/client.rb index 741f332..b3b3a1d 100644 --- a/lib/iron_worker/client.rb +++ b/lib/iron_worker/client.rb @@ -41,6 +41,10 @@ def token @api.token end + def jwt + @api.jwt + end + def project_id @api.project_id end From 46a60bbeeea9f26f0cde3ab89b05f712b4d9bc47 Mon Sep 17 00:00:00 2001 From: Travis Reeder Date: Mon, 26 Oct 2015 11:43:19 -0700 Subject: [PATCH 2/2] bug --- lib/iron_worker/api_client.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iron_worker/api_client.rb b/lib/iron_worker/api_client.rb index 5c22b8c..1d7b999 100644 --- a/lib/iron_worker/api_client.rb +++ b/lib/iron_worker/api_client.rb @@ -27,7 +27,7 @@ def initialize(options = {}) def headers if !@jwt.nil? - super.merge({'Authorization' => "JWT #{@token}"}) + super.merge({'Authorization' => "JWT #{@jwt}"}) else super.merge({'Authorization' => "OAuth #{@token}"}) end