Sha256: 5e7952d552bf58c0bb7e32de3ed3147660d7cff013e2b8095e0ba6aa68511a24

Contents?: true

Size: 981 Bytes

Versions: 4

Compression:

Stored size: 981 Bytes

Contents

require 'omniauth/oauth'
require 'multi_json'

module OmniAuth
  module Strategies
    class Instapaper < OmniAuth::Strategies::XAuth

      def initialize(app, consumer_key = nil, consumer_secret = nil, options = {}, &block)
        client_options = {
          :title => 'Instapaper',
          :site => 'https://www.instapaper.com',
          :access_token_path => '/api/1/oauth/access_token'
        }
        super(app, :instapaper, consumer_key, consumer_secret, client_options, options, &block)
      end

      protected

      def user_data
        @data ||= MultiJson.decode(@access_token.get('/api/1/account/verify_credentials').body)[0]
      end

      def user_info
        {
          'nickname' => user_data['username'],
          'name' => user_data['username']
        }
      end

      def auth_hash
        OmniAuth::Utils.deep_merge(super, {
          'uid' => user_data['user_id'],
          'user_info' => user_info
        })
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
omniauth-0.2.6 oa-oauth/lib/omniauth/strategies/instapaper.rb
oa-oauth-0.2.6 lib/omniauth/strategies/instapaper.rb
omniauth-0.2.5 oa-oauth/lib/omniauth/strategies/instapaper.rb
oa-oauth-0.2.5 lib/omniauth/strategies/instapaper.rb