Sha256: 0b4ac0f8755ebd980361f25297d00ff420967d30b9e13da69973a91272b6a542
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require 'uri' require 'erb' module Twimock module API # OAuthでブラウザ認証するAPI # GET http://api.twimock.com/authenticate?oauth_token=xxx class OAuth class Authenticate < OAuth METHOD = "GET" PATH = "/oauth/authenticate" VIEW_DIRECTORY = File.expand_path("../../../../../view", __FILE__) VIEW_FILE_NAME = "authenticate.html.erb" def call(env) return super unless called?(env) begin request = Rack::Request.new(env) @oauth_token = request.params["oauth_token"] if !validate_request_token(@oauth_token) raise Twimock::Errors::InvalidRequestToken.new end status = 200 body = Twimock::API::OAuth::Authenticate.view(@oauth_token) header = { "Content-Length" => body.bytesize.to_s } [ status, header, [ body ] ] rescue Twimock::Errors::InvalidRequestToken => @error unauthorized rescue => @error internal_server_error end end def self.view(oauth_token) @action_url = Twimock::API::Intent::Sessions::PATH @oauth_token = oauth_token erb = ERB.new(File.read(filepath)) erb.result(binding) end private def self.filepath File.join(VIEW_DIRECTORY, VIEW_FILE_NAME) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
twimock-0.0.2 | lib/twimock/api/oauth/authenticate.rb |
twimock-0.0.1 | lib/twimock/api/oauth/authenticate.rb |