Sha256: 39d36e0d8efabb4cea622d236b0605c2a4dd75589bb1ac488c00fb1827f7ca43

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module OmniAuth
  module Strategies
    class Sina < OmniAuth::Strategies::Auth
      option :name, 'sina'
      option :client_options, {
        :authorize_path => '/oauth/authorize',
        :site => 'http://api.t.sina.com.cn',
        :request_token_path => '/oauth/request_token',
        :access_token_path => '/oauth/access_token'
      }
      
      option :callback_confirmed, true

      uid { access_token.params[:user_id] }

      info do
        {
          :nickname => raw_info['screen_name'],
          :name => raw_info['name'],
          :location => raw_info['location'],
          :image => raw_info['profile_image_url'],
          :description => raw_info['description'],
          :urls => {
            'Website' => raw_info['url'],
            'Sina' => 'http://weibo.com/' + raw_info['screen_name'],
          }
        }
      end
      
      def raw_info
        @raw_info ||= MultiJson.decode(access_token.get('/account/verify_credentials.json').body)
      rescue ::Errno::ETIMEDOUT
        raise ::Timeout::Error
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-sina-0.0.1 lib/omniauth/strategies/sina.rb