Sha256: 768a4fa36fa2572ccbf1d6337113b7f694de8f8f9ec9ea86c333e2261923ce84

Contents?: true

Size: 1.06 KB

Versions: 38

Compression:

Stored size: 1.06 KB

Contents

module OAuth
  # The RequestToken is used for the initial Request.
  # This is normally created by the Consumer object.
  class RequestToken < ConsumerToken

    # Generate an authorization URL for user authorization
    def authorize_url(params = nil)
      params = (params || {}).merge(:oauth_token => self.token)
      build_authorize_url(consumer.authorize_url, params)
    end

    def callback_confirmed?
      params[:oauth_callback_confirmed] == "true"
    end

    # exchange for AccessToken on server
    def get_access_token(options = {}, *arguments)
      response = consumer.token_request(consumer.http_method, (consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options, *arguments)
      OAuth::AccessToken.from_hash(consumer, response)
    end

  protected

    # construct an authorization url
    def build_authorize_url(base_url, params)
      uri = URI.parse(base_url.to_s)
      # TODO doesn't handle array values correctly
      uri.query = params.map { |k,v| [k, CGI.escape(v)] * "=" } * "&"
      uri.to_s
    end
  end
end

Version data entries

38 entries across 37 versions & 20 rubygems

Version Path
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/oauth-0.4.7/lib/oauth/tokens/request_token.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/oauth-0.4.7/lib/oauth/tokens/request_token.rb
oauth-ap-0.4.8 lib/oauth/tokens/request_token.rb
greut-oauth-0.3.6 lib/oauth/tokens/request_token.rb
jwhitmire-oauth-0.3.6.1 lib/oauth/tokens/request_token.rb
mojodna-oauth-0.3.4.1 lib/oauth/tokens/request_token.rb
mojodna-oauth-0.3.5 lib/oauth/tokens/request_token.rb
mojodna-oauth-0.3.6 lib/oauth/tokens/request_token.rb
monkeyhelper-oauth-0.3.5 lib/oauth/tokens/request_token.rb
mzsanford-oauth-0.3.2.2 lib/oauth/tokens/request_token.rb
pelle-oauth-0.3.5 lib/oauth/tokens/request_token.rb
pelle-oauth-0.3.6 lib/oauth/tokens/request_token.rb
sporkd-oauth-0.3.6 lib/oauth/tokens/request_token.rb
oauth-instructure-0.4.10 lib/oauth/tokens/request_token.rb
oauth_weshays-0.4.8.pre2 lib/oauth/tokens/request_token.rb
oauth_weshays-0.4.8.pre lib/oauth/tokens/request_token.rb
oauth-instructure-0.4.9 lib/oauth/tokens/request_token.rb
oauth-instructure-0.4.8 lib/oauth/tokens/request_token.rb
oauth-0.4.7 lib/oauth/tokens/request_token.rb
motionbox-oauth-0.4.5 lib/oauth/tokens/request_token.rb