Sha256: f9605dd1c6309b01767ec4b7ccee0b468a278506781f7b192df9a1bdbd8b2429
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module Pocket # Defines HTTP request methods module OAuth # Return URL for OAuth authorization def authorize_url(options={}) params = access_token_params.merge(options) # Pocket renames `code` to `request_token` for some reason in this call params[:request_token] = params[:code] connection.build_url("/auth/authorize", params).to_s end # Return a Pocket code def get_code(options={}) params = access_token_params.merge(options) response = connection.post 'oauth/request', params results = Hash[URI.decode_www_form(response.body)] code = results['code'] end # Return an access token from authorization def get_access_token(code, options={}) params = access_token_params.merge(options) params = access_token_params.merge(:code => code).merge(options) response = connection.post 'oauth/authorize', params results = Hash[URI.decode_www_form(response.body)] access_token = results['access_token'] end private def access_token_params { :consumer_key => consumer_key } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pocket-ruby-0.0.4 | lib/pocket/oauth.rb |
pocket-ruby-0.0.3 | lib/pocket/oauth.rb |