class PlayStationNetworkAPI::Session
Attributes
token[RW]
Public Class Methods
new(token)
click to toggle source
# File lib/play_station_network_api/session.rb, line 13 def initialize(token) @token = token end
Public Instance Methods
access_token()
click to toggle source
# File lib/play_station_network_api/session.rb, line 24 def access_token oauth_token['access_token'] end
authenticate()
click to toggle source
# File lib/play_station_network_api/session.rb, line 17 def authenticate code, cid = oauth_authorize oauth_token(code) end
Also aliased as: refresh
expiration_date()
click to toggle source
# File lib/play_station_network_api/session.rb, line 28 def expiration_date (Time.now + oauth_token['refresh_token_expires_in']).to_datetime.to_s end
expired?()
click to toggle source
# File lib/play_station_network_api/session.rb, line 32 def expired? expiration_date < DateTime.now.to_s end
oauth_token(code = nil)
click to toggle source
# File lib/play_station_network_api/session.rb, line 63 def oauth_token(code = nil) body = {} if code body = { 'code' => code, 'grant_type' => 'authorization_code', 'redirect_uri' => 'com.playstation.PlayStationApp://redirect' } else body = { 'refresh_token' => token, 'grant_type' => 'refresh_token' } end self.class.post('/authz/v3/oauth/token', headers: { 'Host' => 'ca.account.sony.com', 'Referer' => 'https://my.playstation.com/', 'Authorization' => 'Basic YWM4ZDE2MWEtZDk2Ni00NzI4LWIwZWEtZmZlYzIyZjY5ZWRjOkRFaXhFcVhYQ2RYZHdqMHY=' }, body: { 'scope' => DEFAULT_SCOPES, **body, 'token_format' => 'jwt' } ).parsed_response end