Class: KindeSdk::Client
- Inherits:
-
Object
- Object
- KindeSdk::Client
- Includes:
- FeatureFlags, Permissions
- Defined in:
- lib/kinde_sdk/client.rb,
lib/kinde_sdk/client/permissions.rb,
lib/kinde_sdk/client/feature_flags.rb
Defined Under Namespace
Modules: FeatureFlags, Permissions
Instance Attribute Summary collapse
-
#bearer_token ⇒ Object
Returns the value of attribute bearer_token.
-
#expires_at ⇒ Object
Returns the value of attribute expires_at.
-
#kinde_api_client ⇒ Object
Returns the value of attribute kinde_api_client.
-
#tokens_hash ⇒ Object
Returns the value of attribute tokens_hash.
Instance Method Summary collapse
-
#get_claim(claim, token_type = :access_token) ⇒ Hash
token_type is one of: :access_token, :id_token.
-
#initialize(sdk_api_client, tokens_hash) ⇒ Client
constructor
A new instance of Client.
- #refresh_token ⇒ Object
- #token_expired? ⇒ Boolean
Methods included from Permissions
#get_permission, #get_permissions, #permission_granted?
Methods included from FeatureFlags
#get_boolean_flag, #get_flag, #get_integer_flag, #get_string_flag
Constructor Details
#initialize(sdk_api_client, tokens_hash) ⇒ Client
10 11 12 13 |
# File 'lib/kinde_sdk/client.rb', line 10 def initialize(sdk_api_client, tokens_hash) @kinde_api_client = sdk_api_client (tokens_hash) end |
Instance Attribute Details
#bearer_token ⇒ Object
Returns the value of attribute bearer_token.
8 9 10 |
# File 'lib/kinde_sdk/client.rb', line 8 def bearer_token @bearer_token end |
#expires_at ⇒ Object
Returns the value of attribute expires_at.
8 9 10 |
# File 'lib/kinde_sdk/client.rb', line 8 def expires_at @expires_at end |
#kinde_api_client ⇒ Object
Returns the value of attribute kinde_api_client.
8 9 10 |
# File 'lib/kinde_sdk/client.rb', line 8 def kinde_api_client @kinde_api_client end |
#tokens_hash ⇒ Object
Returns the value of attribute tokens_hash.
8 9 10 |
# File 'lib/kinde_sdk/client.rb', line 8 def tokens_hash @tokens_hash end |
Instance Method Details
#get_claim(claim, token_type = :access_token) ⇒ Hash
token_type is one of: :access_token, :id_token
30 31 32 33 34 35 36 37 38 |
# File 'lib/kinde_sdk/client.rb', line 30 def get_claim(claim, token_type = :access_token) token = tokens_hash[token_type] return unless token value = JWT.decode(token, nil, false)[0][claim] return unless value { name: claim, value: value } end |
#refresh_token ⇒ Object
19 20 21 22 23 24 |
# File 'lib/kinde_sdk/client.rb', line 19 def refresh_token new_tokens_hash = KindeSdk.refresh_token(tokens_hash) (new_tokens_hash) @kinde_api_client = KindeSdk.api_client(tokens_hash["access_token"]) new_tokens_hash end |
#token_expired? ⇒ Boolean
15 16 17 |
# File 'lib/kinde_sdk/client.rb', line 15 def token_expired? expires_at.to_i > 0 && (expires_at <= Time.now.to_i) end |