Class: Twimock::API::Account::VerifyCredentials
- Defined in:
- lib/twimock/api/account/verify_credentials.rb
Constant Summary collapse
- METHOD =
"GET"
- PATH =
"/1.1/account/verify_credentials.json"
- AUTHORIZATION_REGEXP =
/OAuth oauth_consumer_key=\"(.*)\", oauth_nonce=\"(.*)\", oauth_signature=\"(.*)\", oauth_signature_method=\"(.*)\", oauth_timestamp=\"(.*)\", oauth_token=\"(.*)\", oauth_version=\"(.*)\".*/
Instance Method Summary collapse
Methods inherited from OAuth
Constructor Details
This class inherits a constructor from Twimock::API::OAuth
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/twimock/api/account/verify_credentials.rb', line 14 def call(env) return super unless called?(env) begin = env["authorization"] || env["HTTP_AUTHORIZATION"] oauth = () raise Twimock::Errors::InvalidConsumerKey.new if !validate_consumer_key(oauth.consumer_key) application = Twimock::Application.find_by_api_key(oauth.consumer_key) raise Twimock::Errors::InvalidAccessToken.new if !validate_access_token(oauth.token, application.id) access_token = Twimock::AccessToken.find_by_string(oauth.token) user = Twimock::User.find_by_id(access_token.user_id) rescue Twimock::Errors::InvalidAccessToken, Twimock::Errors::InvalidConsumerKey => @error return rescue => @error return internal_server_error end status = '200 OK' body = user.info.to_json header = { "Content-Length" => body.bytesize.to_s } [ status, header, [ body ] ] end |