Class: Twimock::API::OAuth::Authenticate
Constant Summary
collapse
- METHOD =
"GET"
- PATH =
"/oauth/authenticate"
- VIEW_DIRECTORY =
File.expand_path("../../../../../view", __FILE__)
- VIEW_FILE_NAME =
"authenticate.html.erb"
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize
Class Method Details
.view(oauth_token) ⇒ Object
36
37
38
39
40
41
|
# File 'lib/twimock/api/oauth/authenticate.rb', line 36
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
|
Instance Method Details
#call(env) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/twimock/api/oauth/authenticate.rb', line 15
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)
= { "Content-Length" => body.bytesize.to_s }
[ status, , [ body ] ]
rescue Twimock::Errors::InvalidRequestToken => @error
unauthorized
rescue => @error
internal_server_error
end
end
|