Sha256: ad5ca9140ce510096f3b9d7837f41db48c710f4db3de2316297874f412ac309c
Contents?: true
Size: 1.82 KB
Versions: 3
Compression:
Stored size: 1.82 KB
Contents
require 'omniauth/oauth' require 'multi_json' module OmniAuth module Strategies # Authenticate to Facebook utilizing OAuth 2.0 and retrieve # basic user information. # # @example Basic Usage # use OmniAuth::Strategies::Mixi, 'client_id', 'client_secret' class Mixi < OmniAuth::Strategies::OAuth2 # @option options [String] :scope separate the scopes by a space def initialize(app, client_id=nil, client_secret=nil, options={}, &block) client_options = { :authorize_url => 'https://mixi.jp/connect_authorize.pl', :token_url => 'https://secure.mixi-platform.com/2/token', } super(app, :mixi, client_id, client_secret, client_options, options, &block) end def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['entry']['id'], 'user_info' => user_info, 'credentials' => {'refresh_token' => @access_token.refresh_token}, 'extra' => { 'user_hash' => user_data['entry'], }, } ) end def user_data @data ||= MultiJson.decode(@access_token.get( 'http://api.mixi-platform.com/2/people/@me/@self', {'oauth_token' => @access_token.token} )) end def request_phase options[:scope] ||= 'r_profile' options[:display] ||= 'pc' options[:response_type] ||= 'code' super end def callback_phase options[:grant_type] ||= 'authorization_code' super end def user_info { 'nickname' => user_data['entry']['displayName'], 'image' => user_data['entry']['thumbnailUrl'], 'urls' => { :profile => user_data['entry']['profileUrl'], }, } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oa-oauth-0.3.2 | lib/omniauth/strategies/oauth2/mixi.rb |
oa-oauth-0.3.0 | lib/omniauth/strategies/oauth2/mixi.rb |
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth2/mixi.rb |