Class: Poke::API::Auth::PTC
- Inherits:
-
Object
- Object
- Poke::API::Auth::PTC
- Includes:
- Logging
- Defined in:
- lib/poke-api/auth/ptc.rb
Constant Summary collapse
- PTC_LOGIN_URL =
'https://sso.pokemon.com/sso/login?service=https%3A%2F%2Fsso.pokemon.com' \ '%2Fsso%2Foauth2.0%2FcallbackAuthorize'.freeze
- PTC_LOGIN_OAUTH =
'https://sso.pokemon.com/sso/oauth2.0/accessToken'.freeze
- PTC_LOGIN_CLIENT_SECRET =
'w8ScCUXJQc6kXKw8FiOhd8Fixzht18Dq3PEVkUCP5ZPxtgyWsbTvWHFLm2wNY0JR'.freeze
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#expiry ⇒ Object
readonly
Returns the value of attribute expiry.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(username, password, _refresh_token) ⇒ PTC
constructor
A new instance of PTC.
Methods included from Logging
formatter=, log_level=, #logger
Constructor Details
#initialize(username, password, _refresh_token) ⇒ PTC
Returns a new instance of PTC.
17 18 19 20 21 22 23 |
# File 'lib/poke-api/auth/ptc.rb', line 17 def initialize(username, password, _refresh_token) @username = username @password = password @provider = 'ptc' @client = HTTPClient.new(agent_name: 'PokeAPI/0.0.1') @expiry = 0 end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
10 11 12 |
# File 'lib/poke-api/auth/ptc.rb', line 10 def access_token @access_token end |
#expiry ⇒ Object (readonly)
Returns the value of attribute expiry.
10 11 12 |
# File 'lib/poke-api/auth/ptc.rb', line 10 def expiry @expiry end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
10 11 12 |
# File 'lib/poke-api/auth/ptc.rb', line 10 def provider @provider end |
Instance Method Details
#connect ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/poke-api/auth/ptc.rb', line 25 def connect resp = @client.get_content(PTC_LOGIN_URL) parsed_resp = JSON.parse(resp) data = { username: @username, password: @password, _eventId: 'submit', lt: parsed_resp['lt'], execution: parsed_resp['execution'] } fetch_ticket(data) end |