class

Comrade::Token

Inherits Reference < Object

Represents OAuth tokens returned by providers

Constructors

from_h(hash : Hash(String, JSON::Any::Type)) : Token

Create token from hash

Source
from_json(json : String | IO) : Token

Create token from JSON response

Source
from_json_object(data : JSON::Any) : Token

Create token from JSON::Any object

Source
from_workos_response(data : JSON::Any) : Token

Create token from WorkOS response

Source
new(access_token : String, refresh_token : String | Nil = nil, expires_in : Int32 | Nil = nil, scope : String | Nil = nil, token_type : String | Nil = nil, created_at : Time = Time.utc)
Source

Instance methods

access_token
Source
created_at
Source
expired?

Check if token is expired

Source
expires_at

Get expiration time

Source
expires_in
Source
expiring_soon?(buffer : Int32 = 300) : Bool

Check if token is about to expire (within 5 minutes)

Source
refresh_token
Source
refreshable?

Check if token has a refresh token

Source
scope
Source
to_h

Convert to hash

Source
to_json

Convert to JSON

Source
token_type
Source