Sha256: fd597a9a8cd565e40a4484d52b8f6d360855f75221d9ed1c4fe4afff30fe03b6
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 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::Instagram, 'client_id', 'client_secret' class Instagram < 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://api.instagram.com/oauth/authorize', :token_url => 'https://api.instagram.com/oauth/access_token', } super(app, :instagram, client_id, client_secret, client_options, options, &block) end def auth_hash OmniAuth::Utils.deep_merge( super, { 'uid' => user_data['data']['id'], 'user_info' => user_info, 'extra' => { 'user_hash' => user_data['data'], } } ) end def request_phase options[:scope] ||= 'basic' options[:response_type] ||= 'code' super end def callback_phase options[:grant_type] ||= 'authorization_code' super end def user_data @access_token.options.merge!({:param_name => 'access_token', :mode => :query}) @data ||= MultiJson.decode(@access_token.get('/v1/users/self')) end def user_info { 'nickname' => user_data['data']['username'], 'name' => user_data['data']['full_name'], 'image' => user_data['data']['profile_picture'], } 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/instagram.rb |
oa-oauth-0.3.0 | lib/omniauth/strategies/oauth2/instagram.rb |
oa-oauth-0.3.0.rc3 | lib/omniauth/strategies/oauth2/instagram.rb |