Class: AzureBlob::IdentityToken

Inherits:
Object
  • Object
show all
Defined in:
lib/azure_blob/identity_token.rb

Constant Summary collapse

RESOURCE_URI =
"https://storage.azure.com/"
EXPIRATION_BUFFER =

10 minutes

600
IDENTITY_ENDPOINT =
ENV["IDENTITY_ENDPOINT"] || "http://169.254.169.254/metadata/identity/oauth2/token"
API_VERSION =
ENV["IDENTITY_ENDPOINT"] ? "2019-08-01" : "2018-02-01"

Instance Method Summary collapse

Constructor Details

#initialize(principal_id: nil) ⇒ IdentityToken

Returns a new instance of IdentityToken.



11
12
13
14
15
16
17
18
19
# File 'lib/azure_blob/identity_token.rb', line 11

def initialize(principal_id: nil)
  @identity_uri = URI.parse(IDENTITY_ENDPOINT)
  params = {
    'api-version': API_VERSION,
    resource: RESOURCE_URI,
  }
  params[:principal_id] = principal_id if principal_id
  @identity_uri.query = URI.encode_www_form(params)
end

Instance Method Details

#to_sObject



21
22
23
24
# File 'lib/azure_blob/identity_token.rb', line 21

def to_s
  refresh
  token
end