class OmniAuth::Strategies::CodeSchool
Authenticate to Code School with OAuth 2.0 and retrieve basic user information.
@example Basic Usage
use OmniAuth::Strategies::CodeSchool, 'client_id', 'client_secret'
Public Class Methods
new(app, client_id = nil, client_secret = nil, options = {}, &block)
click to toggle source
@param [Rack Application] app standard middleware application parameter @param [String] client_id the application id as [registered on Facebook](www.facebook.com/developers/) @param [String] client_secret the application secret as registered on Facebook @option options [String] :scope ('email,offline_access') comma-separated extended permissions such as `email` and `manage_pages`
Calls superclass method
# File lib/oa-codeschool.rb, line 21 def initialize(app, client_id = nil, client_secret = nil, options = {}, &block) super(app, :code_school, client_id, client_secret, { :site => self.class.base_uri.presence || "http://localhost:3000", :authorize_url => "/oauth2/authorize", :token_url => "/oauth2/token" }, options, &block) end
Public Instance Methods
auth_hash()
click to toggle source
Calls superclass method
# File lib/oa-codeschool.rb, line 57 def auth_hash OmniAuth::Utils.deep_merge(super, { 'uid' => user_data['id'], 'user_info' => user_info, 'extra' => {'user_hash' => user_data} }) end
callback_phase()
click to toggle source
Calls superclass method
# File lib/oa-codeschool.rb, line 34 def callback_phase options[:grant_type] ||= 'authorization_code' super end
client()
click to toggle source
memoize the client or else setting up Faraday stubs does not work
Calls superclass method
# File lib/oa-codeschool.rb, line 44 def client @_client ||= super end
request_phase()
click to toggle source
Calls superclass method
# File lib/oa-codeschool.rb, line 29 def request_phase options[:response_type] ||= "code" super end
user_data()
click to toggle source
# File lib/oa-codeschool.rb, line 39 def user_data @data ||= @access_token.get('/api/v2/user.json').parsed['user'] end
user_info()
click to toggle source
# File lib/oa-codeschool.rb, line 48 def user_info { 'nickname' => user_data["username"], 'email' => user_data["email"], 'name' => user_data['name'], 'image' => user_data['avatar'] } end