Class: Bskyrb::Session
- Inherits:
-
Object
- Object
- Bskyrb::Session
- Includes:
- RequestUtils
- Defined in:
- lib/bskyrb/session.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#did ⇒ Object
readonly
Returns the value of attribute did.
-
#pds ⇒ Object
readonly
Returns the value of attribute pds.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
Instance Method Summary collapse
-
#initialize(credentials, pds, should_open = true) ⇒ Session
constructor
A new instance of Session.
- #open! ⇒ Object
Methods included from RequestUtils
#at_post_link, #create_record_uri, #default_authenticated_headers, #default_headers, #delete_record_uri, #get_post_thread_uri, #mute_actor_uri, #query_obj_to_query_params, #resolve_handle, #upload_blob_uri
Constructor Details
#initialize(credentials, pds, should_open = true) ⇒ Session
Returns a new instance of Session.
94 95 96 97 98 |
# File 'lib/bskyrb/session.rb', line 94 def initialize(credentials, pds, should_open = true) @credentials = credentials @pds = pds open! if should_open end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
92 93 94 |
# File 'lib/bskyrb/session.rb', line 92 def access_token @access_token end |
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
92 93 94 |
# File 'lib/bskyrb/session.rb', line 92 def credentials @credentials end |
#did ⇒ Object (readonly)
Returns the value of attribute did.
92 93 94 |
# File 'lib/bskyrb/session.rb', line 92 def did @did end |
#pds ⇒ Object (readonly)
Returns the value of attribute pds.
92 93 94 |
# File 'lib/bskyrb/session.rb', line 92 def pds @pds end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
92 93 94 |
# File 'lib/bskyrb/session.rb', line 92 def refresh_token @refresh_token end |
Instance Method Details
#open! ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/bskyrb/session.rb', line 100 def open! uri = URI("#{pds}/xrpc/com.atproto.server.createSession") response = HTTParty.post( uri, body: { identifier: credentials.username, password: credentials.pw }.to_json, headers: default_headers, ) raise if response.code == 401 @access_token = response["accessJwt"] @refresh_token = response["refreshJwt"] @did = response["did"] end |