Sha256: 3508bd9e81c787485d96e3e4d4d71476e5af1ebb9655efa9e8d9cc9ac3da0e29
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
class Rhapsody::Client attr_accessor :api_key, :api_secret, :auth_code, :redirect_url, :raw_reponse, :json_response, :access_token, :refresh_token, :expires_in class << self end def initialize(options) @api_key = options['api_key'] @api_secret = options['api_secret'] @auth_code = options['auth_code'] @redirect_url = options['redirect_url'] end def connect host_url = 'https://api.rhapsody.com' oauth_path = '/oauth/access_token' connection = Faraday.new(:url => host_url) do |faraday| faraday.request :url_encoded faraday.response :logger faraday.adapter Faraday.default_adapter end post_hash = { client_id: @api_key, client_secret: @api_secret, response_type: 'code', grant_type: 'authorization_code', code: @auth_code, redirect_uri: @redirect_url } @raw_response = connection.post(oauth_path, post_hash) @json_response = JSON.parse(@raw_response) @access_token = @json_response['access_token'] @refresh_token = @json_response['refresh_token'] @expires_in = @json_response['expires_in'] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rhapsody-0.0.3 | lib/rhapsody/models/client.rb |