Class: OmniAuth::Strategies::YahooJp

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/yahoojp.rb

Instance Method Summary collapse

Instance Method Details

#build_access_tokenObject



75
76
77
78
79
80
81
82
83
84
# File 'lib/omniauth/strategies/yahoojp.rb', line 75

def build_access_token
  token_params = {
    :code => request.params['code'],
    :redirect_uri => callback_url,
    :grant_type => 'authorization_code',
    :headers => {'Authorization' => HTTPAuth::Basic.pack_authorization(client.id, client.secret)}
  }

  client.get_token(token_params);
end

#callback_urlObject



86
87
88
# File 'lib/omniauth/strategies/yahoojp.rb', line 86

def callback_url
  full_host + script_name + callback_path
end

#id_tokenObject



90
91
92
# File 'lib/omniauth/strategies/yahoojp.rb', line 90

def id_token
  access_token&.params&.dig('id_token')
end

#id_token_claimsObject



94
95
96
# File 'lib/omniauth/strategies/yahoojp.rb', line 94

def id_token_claims
  JSON::JWT.decode(id_token, :skip_verification)
end

#prune!(hash) ⇒ Object



68
69
70
71
72
73
# File 'lib/omniauth/strategies/yahoojp.rb', line 68

def prune!(hash)
  hash.delete_if do |_, value|
    prune!(value) if value.is_a?(Hash)
    value.nil? || (value.respond_to?(:empty?) && value.empty?)
  end
end

#raw_infoObject



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/omniauth/strategies/yahoojp.rb', line 54

def raw_info
  @raw_info ||= if options.userinfo_access
    access_token.options[:mode] = :header
    access_token.get(options.client_options.userinfo_url).parsed
  elsif id_token
    id_token_claims.slice(:sub).merge(
      id_token: id_token,
      id_token_claims: id_token_claims,
    )
  else
    {}
  end
end

#request_phaseObject



20
21
22
# File 'lib/omniauth/strategies/yahoojp.rb', line 20

def request_phase
  super
end