Class: Azure::Auth::TokenProvider::Token
- Inherits:
-
Object
- Object
- Azure::Auth::TokenProvider::Token
- Defined in:
- lib/azure/auth/token_provider/token.rb
Overview
Azure OAuth2 access token
Instance Attribute Summary collapse
-
#access_token ⇒ String
readonly
JWT access token.
-
#client_id ⇒ String
readonly
Client Id.
-
#expires_in ⇒ Number
readonly
TTL in seconds.
-
#expires_on ⇒ Time
readonly
Date and time when token expires.
-
#ext_expires_in ⇒ Time
readonly
Ext expires in.
-
#not_before ⇒ Time
readonly
Date and time before which token is not valid.
-
#resource ⇒ String
readonly
URI of resource token is valid for.
-
#subscription ⇒ String
readonly
Azure subscription id.
-
#tenant ⇒ String
readonly
Azure app tenant id.
-
#token_type ⇒ String
readonly
Token type.
Instance Method Summary collapse
-
#expired? ⇒ Boolean
Is token expired?.
-
#initialize(access_token, expires_on, token_type, ext) ⇒ Token
constructor
Initializes new instance of Token.
Constructor Details
#initialize(access_token, expires_on, token_type, ext) ⇒ Token
Initializes new instance of Token
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/azure/auth/token_provider/token.rb', line 39 def initialize(access_token, expires_on, token_type, ext) @access_token = access_token @expires_on = expires_on @token_type = token_type @subscription = ext.fetch(:subscription, nil) @tenant = ext.fetch(:tenant, nil) @client_id = ext.fetch(:client_id, nil) @expires_in = ext.fetch(:expires_in, nil) @ext_expires_in = ext.fetch(:ext_expires_in, nil) @not_before = ext.fetch(:not_before, nil) @resource = ext.fetch(:resource, nil) end |
Instance Attribute Details
#access_token ⇒ String (readonly)
JWT access token
55 56 57 |
# File 'lib/azure/auth/token_provider/token.rb', line 55 def access_token @access_token end |
#client_id ⇒ String (readonly)
Client Id
75 76 77 |
# File 'lib/azure/auth/token_provider/token.rb', line 75 def client_id @client_id end |
#expires_in ⇒ Number (readonly)
TTL in seconds
79 80 81 |
# File 'lib/azure/auth/token_provider/token.rb', line 79 def expires_in @expires_in end |
#expires_on ⇒ Time (readonly)
Date and time when token expires
59 60 61 |
# File 'lib/azure/auth/token_provider/token.rb', line 59 def expires_on @expires_on end |
#ext_expires_in ⇒ Time (readonly)
Ext expires in
83 84 85 |
# File 'lib/azure/auth/token_provider/token.rb', line 83 def ext_expires_in @ext_expires_in end |
#not_before ⇒ Time (readonly)
Date and time before which token is not valid
87 88 89 |
# File 'lib/azure/auth/token_provider/token.rb', line 87 def not_before @not_before end |
#resource ⇒ String (readonly)
URI of resource token is valid for
91 92 93 |
# File 'lib/azure/auth/token_provider/token.rb', line 91 def resource @resource end |
#subscription ⇒ String (readonly)
Azure subscription id
63 64 65 |
# File 'lib/azure/auth/token_provider/token.rb', line 63 def subscription @subscription end |
#tenant ⇒ String (readonly)
Azure app tenant id
67 68 69 |
# File 'lib/azure/auth/token_provider/token.rb', line 67 def tenant @tenant end |
#token_type ⇒ String (readonly)
Token type
71 72 73 |
# File 'lib/azure/auth/token_provider/token.rb', line 71 def token_type @token_type end |
Instance Method Details
#expired? ⇒ Boolean
Is token expired?
95 96 97 |
# File 'lib/azure/auth/token_provider/token.rb', line 95 def expired? Time.now > @expires_on end |