lib/omniauth/strategies/github.rb in oa-oauth-0.2.4 vs lib/omniauth/strategies/github.rb in oa-oauth-0.2.5
- old
+ new
@@ -1,11 +1,11 @@
require 'omniauth/oauth'
require 'multi_json'
module OmniAuth
module Strategies
- # OAuth 2.0 based authentication with GitHub. In order to
+ # OAuth 2.0 based authentication with GitHub. In order to
# sign up for an application, you need to [register an application](http://github.com/account/applications/new)
# and provide the proper credentials to this middleware.
class GitHub < OAuth2
# @param [Rack Application] app standard middleware application argument
# @param [String] client_id the application ID for your client
@@ -14,20 +14,20 @@
client_options = {
:site => 'https://github.com/',
:authorize_path => '/login/oauth/authorize',
:access_token_path => '/login/oauth/access_token'
}
-
+
super(app, :github, client_id, client_secret, client_options, options, &block)
end
-
+
protected
-
+
def user_data
@data ||= MultiJson.decode(@access_token.get('/api/v2/json/user/show'))['user']
end
-
+
def user_info
{
'nickname' => user_data["login"],
'email' => user_data['email'],
'name' => user_data['name'],
@@ -35,10 +35,10 @@
'GitHub' => "http://github.com/#{user_data['login']}",
'Blog' => user_data["blog"],
}
}
end
-
+
def auth_hash
OmniAuth::Utils.deep_merge(super, {
'uid' => user_data['id'],
'user_info' => user_info,
'extra' => {'user_hash' => user_data}