Class: Lono::SessionToken
- Inherits:
-
Object
- Object
- Lono::SessionToken
- Defined in:
- lib/lono-api/session_token.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#token_type ⇒ Object
readonly
Returns the value of attribute token_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(session_token, token_type) ⇒ SessionToken
constructor
A new instance of SessionToken.
Constructor Details
#initialize(session_token, token_type) ⇒ SessionToken
Returns a new instance of SessionToken.
5 6 7 8 |
# File 'lib/lono-api/session_token.rb', line 5 def initialize(session_token, token_type) @access_token = session_token @token_type = token_type || "bearer" end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
3 4 5 |
# File 'lib/lono-api/session_token.rb', line 3 def access_token @access_token end |
#token_type ⇒ Object (readonly)
Returns the value of attribute token_type.
3 4 5 |
# File 'lib/lono-api/session_token.rb', line 3 def token_type @token_type end |
Class Method Details
.fetch ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lono-api/session_token.rb', line 11 def fetch response = Unirest.post("http://make.lono.io/oauth/token", headers: {Accept: "application/json"}, parameters: { grant_type: "authorization_code", client_id: Lono.client_id, client_secret: Lono.client_secret, code: Lono.auth_token } ) if response.body['access_token'] self.new(response.body['access_token'], response.body['token_type']) else raise Lono::NoTokenError.new(response.body['error']) end end |