Sha256: 1c8def695f5bcf586a8a4d4b4600536ff5e6233d774a99982ee9c848f7e02f4c

Contents?: true

Size: 881 Bytes

Versions: 1

Compression:

Stored size: 881 Bytes

Contents

module Jibeset
  # Defines HTTP request methods
  module OAuth
    # Return URL for OAuth authorization
    def authorize_url(options={})
      options[:response_type] ||= "code"
      options[:redirect_uri] = oauth_callback
      authorize_path = options[:authorize_path] || "/oauth/authorize/"
      params = access_token_params.merge(options)
      connection.build_url(authorize_path, params).to_s
    end

    # Return an access token from authorization
    def get_access_token(code, options={})
      options[:grant_type] ||= "authorization_code"
      options[:redirect_uri] = oauth_callback
      params = access_token_params.merge(options)
      post("/oauth/token/", params.merge(:code => code), false, unformatted=true)
    end
    

    private

    def access_token_params
      { :client_id => client_id,
        :client_secret => client_secret }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jibeset-0.2 lib/jibeset/oauth.rb