Sha256: 2e91c8a8cf52b8a7e0fe3007dfaf02710c09a06b50fd452319df66e86164660f
Contents?: true
Size: 979 Bytes
Versions: 11
Compression:
Stored size: 979 Bytes
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 # exchange for AccessToken on server def get_access_token(options = {}) response = consumer.token_request(consumer.http_method, (consumer.access_token_url? ? consumer.access_token_url : consumer.access_token_path), self, options) 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
11 entries across 11 versions & 5 rubygems