class OmniAuth::Strategies::Apple
Public Instance Methods
callback_url()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 38 def callback_url options[:redirect_uri] || (full_host + script_name + callback_path) end
client()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 34 def client ::OAuth2::Client.new(options.client_id, client_secret, deep_symbolize(options.client_options)) end
Private Instance Methods
client_secret()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 69 def client_secret payload = { iss: options.team_id, aud: 'https://appleid.apple.com', sub: options.client_id, iat: Time.now.to_i, exp: Time.now.to_i + 60 } headers = { kid: options.key_id } ::JWT.encode(payload, private_key, 'ES256', headers) end
email()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 57 def email user_info['email'] || id_info['email'] end
first_name()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 61 def first_name user_info.dig('name', 'firstName') end
id_info()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 44 def id_info id_token = request.params['id_token'] || access_token.params['id_token'] log(:info, "id_token: #{id_token}") @id_info ||= ::JWT.decode(id_token, nil, false)[0] # payload after decoding end
last_name()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 65 def last_name user_info.dig('name', 'lastName') end
private_key()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 82 def private_key ::OpenSSL::PKey::EC.new(options.pem) end
user_info()
click to toggle source
# File lib/omniauth/strategies/apple.rb, line 50 def user_info return {} unless request.params['user'].present? log(:info, "user_info: #{request.params['user']}") @user_info ||= JSON.parse(request.params['user']) end