class JIRA::OauthClient
Constants
- DEFAULT_OPTIONS
Attributes
consumer[RW]
options[R]
Public Class Methods
new(options)
click to toggle source
# File lib/jira/oauth_client.rb, line 33 def initialize(options) @options = DEFAULT_OPTIONS.merge(options) @consumer = init_oauth_consumer(@options) end
Public Instance Methods
access_token()
click to toggle source
Returns the current access token. Raises an JIRA::Client::UninitializedAccessTokenError exception if it is not set.
# File lib/jira/oauth_client.rb, line 69 def access_token raise UninitializedAccessTokenError.new unless @access_token @access_token end
init_access_token(params)
click to toggle source
Initialises and returns a new access token from the params hash returned by the OAuth transaction.
# File lib/jira/oauth_client.rb, line 58 def init_access_token(params) @access_token = request_token.get_access_token(params) end
init_oauth_consumer(options)
click to toggle source
# File lib/jira/oauth_client.rb, line 38 def init_oauth_consumer(options) @options[:request_token_path] = @options[:context_path] + @options[:request_token_path] @options[:authorize_path] = @options[:context_path] + @options[:authorize_path] @options[:access_token_path] = @options[:context_path] + @options[:access_token_path] OAuth::Consumer.new(@options[:consumer_key],@options[:consumer_secret],@options) end
make_request(http_method, path, body='', headers={})
click to toggle source
# File lib/jira/oauth_client.rb, line 74 def make_request(http_method, path, body='', headers={}) case http_method when :delete, :get, :head response = access_token.send http_method, path, headers when :post, :put response = access_token.send http_method, path, body, headers end response end
request_token()
click to toggle source
Returns the current request token if it is set, else it creates and sets a new token.
# File lib/jira/oauth_client.rb, line 47 def request_token @request_token ||= get_request_token end
set_access_token(token, secret)
click to toggle source
Sets the access token from a preexisting token and secret.
# File lib/jira/oauth_client.rb, line 63 def set_access_token(token, secret) @access_token = OAuth::AccessToken.new(@consumer, token, secret) end
set_request_token(token, secret)
click to toggle source
Sets the request token from a given token and secret.
# File lib/jira/oauth_client.rb, line 52 def set_request_token(token, secret) @request_token = OAuth::RequestToken.new(@consumer, token, secret) end