Class: Azure::Auth::TokenProvider::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/azure/auth/token_provider/token.rb

Overview

Azure OAuth2 access token

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, expires_on, token_type, ext) ⇒ Token

Initializes new instance of Token

Parameters:

  • access_token (String)

    JWT access token

  • expires_on (Time)

    Date and time when token expires

  • token_type (String)

    Token type

  • ext (Hash)

    extra data



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_tokenString (readonly)

JWT access token

Returns:

  • (String)


55
56
57
# File 'lib/azure/auth/token_provider/token.rb', line 55

def access_token
  @access_token
end

#client_idString (readonly)

Client Id

Returns:

  • (String)


75
76
77
# File 'lib/azure/auth/token_provider/token.rb', line 75

def client_id
  @client_id
end

#expires_inNumber (readonly)

TTL in seconds

Returns:

  • (Number)


79
80
81
# File 'lib/azure/auth/token_provider/token.rb', line 79

def expires_in
  @expires_in
end

#expires_onTime (readonly)

Date and time when token expires

Returns:

  • (Time)


59
60
61
# File 'lib/azure/auth/token_provider/token.rb', line 59

def expires_on
  @expires_on
end

#ext_expires_inTime (readonly)

Ext expires in

Returns:

  • (Time)


83
84
85
# File 'lib/azure/auth/token_provider/token.rb', line 83

def ext_expires_in
  @ext_expires_in
end

#not_beforeTime (readonly)

Date and time before which token is not valid

Returns:

  • (Time)


87
88
89
# File 'lib/azure/auth/token_provider/token.rb', line 87

def not_before
  @not_before
end

#resourceString (readonly)

URI of resource token is valid for

Returns:

  • (String)


91
92
93
# File 'lib/azure/auth/token_provider/token.rb', line 91

def resource
  @resource
end

#subscriptionString (readonly)

Azure subscription id

Returns:

  • (String)


63
64
65
# File 'lib/azure/auth/token_provider/token.rb', line 63

def subscription
  @subscription
end

#tenantString (readonly)

Azure app tenant id

Returns:

  • (String)


67
68
69
# File 'lib/azure/auth/token_provider/token.rb', line 67

def tenant
  @tenant
end

#token_typeString (readonly)

Token type

Returns:

  • (String)


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?

Returns:

  • (Boolean)


95
96
97
# File 'lib/azure/auth/token_provider/token.rb', line 95

def expired?
  Time.now > @expires_on
end