Sha256: d2800f85d612d06565b070af759c04807e4a84ae062a8590d3d9db2b633bbeae
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'uri' require 'erb' module Twimock module API # 認証キャンセル後の画面を返すAPI # POST http://api.twimock.com/oauth/authorize class OAuth class Authorize < OAuth METHOD = "GET" PATH = "/oauth/authorize" def call(env) return super unless called?(env) begin request = Rack::Request.new(env) @oauth_token = request.params["oauth_token"] @cancel = request.params["cancel"] if !validate_request_token(@oauth_token) raise Twimock::Errors::InvalidRequestToken.new elsif @cancel == "true" raise Twimock::Errors::OAuthCancelled.new end status = 200 body = "" header = { "Content-Length" => body.bytesize.to_s } [ status, header, [ body ] ] rescue Twimock::Errors::InvalidRequestToken => @error unauthorized rescue Twimock::Errors::OAuthCancelled => @error oauth_cancelled rescue => @error internal_server_error end end private def oauth_cancelled status = 200 body = Twimock::API::OAuth::Cancelled.view(@oauth_token) header = { "Content-Length" => body.bytesize.to_s } [ status, header, [ body ] ] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twimock-0.0.2 | lib/twimock/api/oauth/authorize.rb |