lib/omniauth/strategies/line.rb in omniauth-ljne-0.1.5 vs lib/omniauth/strategies/line.rb in omniauth-ljne-0.1.6
- old
+ new
@@ -4,11 +4,11 @@
module OmniAuth
module Strategies
class Line < OmniAuth::Strategies::OAuth2
option :name, 'line'
option :scope, 'profile openid email'
-
+
option :client_options, {
site: 'https://access.line.me',
authorize_url: '/oauth2/v2.1/authorize',
token_url: '/oauth2/v2.1/token'
}
@@ -17,11 +17,11 @@
options[:client_options][:site] = 'https://api.line.me'
super
end
alias :old_callback_url :callback_url
-
+
def callback_url
if request.params['callback_url']
request.params['callback_url']
else
old_callback_url
@@ -35,20 +35,27 @@
super
else
URI(params['callback_url']).path
end
end
-
+
uid { raw_info['userId'] }
info do
{
name: raw_info['displayName'],
- email: raw_info['email'],
- image: raw_info['pictureUrl'],
- description: raw_info['statusMessage'],
- info: raw_info
+ email: extra["email"],
+ image: raw_info['pictureUrl']
}
+ end
+
+ extra do
+ hash = {}
+ hash[:id_token] = access_token['id_token']
+ if !options[:skip_jwt] && !access_token['id_token'].nil?
+ decoded = ::JWT.decode(access_token['id_token'], nil, false).first
+ hash[:id_info] = decoded
+ end
end
def raw_info
@raw_info ||= JSON.load(access_token.get('v2/profile').body)
rescue ::Errno::ETIMEDOUT