Module: Instapaper::API::OAuth

Included in:
Instapaper::API
Defined in:
lib/instapaper/api/oauth.rb

Overview

Defines methods related to OAuth

Instance Method Summary collapse

Instance Method Details

#access_token(username, password) ⇒ Object

Gets an OAuth access token for a user.



9
10
11
12
13
14
15
# File 'lib/instapaper/api/oauth.rb', line 9

def access_token(username, password)
  response = perform_post_with_unparsed_response('/api/1.1/oauth/access_token', x_auth_username: username, x_auth_password: password, x_auth_mode: 'client_auth')
  parsed_response = QLineParser.parse(response)
  raise Instapaper::Error::OAuthError, parsed_response['error'] if parsed_response.key?('error')

  Instapaper::Credentials.new(parsed_response)
end