Sha256: 38ed891e053192e26f56b3c96139e275a6f6c766425bc7212a3d72d9f7a7d62a

Contents?: true

Size: 920 Bytes

Versions: 3

Compression:

Stored size: 920 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 = {
          :token_url => 'https://www.instapaper.com/api/1/oauth/access_token',
        }
        super(app, :instapaper, consumer_key, consumer_secret, client_options, options, &block)
      end

      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

3 entries across 3 versions & 1 rubygems

Version Path
oa-oauth-0.3.2 lib/omniauth/strategies/xauth/instapaper.rb
oa-oauth-0.3.0 lib/omniauth/strategies/xauth/instapaper.rb
oa-oauth-0.3.0.rc3 lib/omniauth/strategies/xauth/instapaper.rb