Class: OmniAuth::Strategies::Playstation
- Inherits:
-
OAuth2
- Object
- OAuth2
- OmniAuth::Strategies::Playstation
- Defined in:
- lib/omniauth/strategies/playstation.rb
Constant Summary collapse
- @@force_ssl =
true
Class Method Summary collapse
- .force_ssl ⇒ Object
- .force_ssl=(value) ⇒ Object
- .psn_auth_env ⇒ Object
- .psn_env ⇒ Object
- .psn_env=(value = 'sp-int') ⇒ Object
- .set_client_options ⇒ Object
Instance Method Summary collapse
- #build_access_token ⇒ Object
- #force_ssl ⇒ Object
- #psn_env ⇒ Object
- #raw_info ⇒ Object
- #redirect_uri ⇒ Object
- #request_phase ⇒ Object
Class Method Details
.force_ssl ⇒ Object
25 26 27 |
# File 'lib/omniauth/strategies/playstation.rb', line 25 def self.force_ssl @@force_ssl end |
.force_ssl=(value) ⇒ Object
21 22 23 |
# File 'lib/omniauth/strategies/playstation.rb', line 21 def self.force_ssl= value @@force_ssl = value end |
.psn_auth_env ⇒ Object
29 30 31 |
# File 'lib/omniauth/strategies/playstation.rb', line 29 def self.psn_auth_env psn_env == 'np' ? '' : "#{psn_env}." end |
.psn_env ⇒ Object
17 18 19 |
# File 'lib/omniauth/strategies/playstation.rb', line 17 def self.psn_env [:psn_env] end |
.psn_env=(value = 'sp-int') ⇒ Object
12 13 14 15 |
# File 'lib/omniauth/strategies/playstation.rb', line 12 def self.psn_env= value = 'sp-int' option :psn_env, value end |
.set_client_options ⇒ Object
33 34 35 36 37 38 |
# File 'lib/omniauth/strategies/playstation.rb', line 33 def self. option :client_options, { site: "https://auth.api.#{psn_auth_env}sonyentertainmentnetwork.com", info_url: "https://vl.api.#{psn_env}.ac.playstation.net/vl/api/v1/s2s/users/me/info" } end |
Instance Method Details
#build_access_token ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/omniauth/strategies/playstation.rb', line 60 def build_access_token # generate Authorization header auth = client.connection.basic_auth(.client_id, .client_secret) .token_params[:headers] = { "Authorization" => auth } # remove code and state from callback_url filtered_query_string = query_string.split('&').reject { |param| param =~ /code=|state=/ }.join url = full_host + script_name + callback_path + filtered_query_string # original implementation using url instead of callback_url verifier = request.params["code"] client.auth_code.get_token(verifier, {:redirect_uri => url}.merge(token_params.to_hash(:symbolize_keys => true)), deep_symbolize(.auth_token_params)) end |
#force_ssl ⇒ Object
44 45 46 |
# File 'lib/omniauth/strategies/playstation.rb', line 44 def force_ssl @@force_ssl end |
#psn_env ⇒ Object
40 41 42 |
# File 'lib/omniauth/strategies/playstation.rb', line 40 def psn_env self.class.psn_env end |
#raw_info ⇒ Object
89 90 91 92 93 94 |
# File 'lib/omniauth/strategies/playstation.rb', line 89 def raw_info auth_headers = { Authorization: client.connection.basic_auth(.client_id, .client_secret) } @raw_info ||= JSON.parse(self.client.connection.run_request(:get, "https://auth.api.#{self.class.psn_auth_env}sonyentertainmentnetwork.com/2.0/oauth/token/#{self.access_token.token}", '', auth_headers).body) rescue ::Errno::ETIMEDOUT raise ::Timeout::Error end |
#redirect_uri ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/omniauth/strategies/playstation.rb', line 52 def redirect_uri if force_ssl callback_url.gsub(/https?/,'https') else callback_url end end |
#request_phase ⇒ Object
48 49 50 |
# File 'lib/omniauth/strategies/playstation.rb', line 48 def request_phase redirect client.auth_code.({:redirect_uri => redirect_uri}.merge()) end |