Class: MsRestAzure::ApplicationTokenProvider
- Inherits:
-
MsRest::TokenProvider
- Object
- MsRest::TokenProvider
- MsRestAzure::ApplicationTokenProvider
- Defined in:
- lib/ms_rest_azure/credentials/application_token_provider.rb
Overview
Class that provides access to authentication token.
Instance Method Summary collapse
-
#get_authentication_header ⇒ String
Returns the string value which needs to be attached to HTTP request header in order to be authorized.
-
#initialize(tenant_id, client_id, client_secret, settings = ActiveDirectoryServiceSettings.get_azure_settings) ⇒ ApplicationTokenProvider
constructor
Creates and initialize new instance of the ApplicationTokenProvider class.
Constructor Details
#initialize(tenant_id, client_id, client_secret, settings = ActiveDirectoryServiceSettings.get_azure_settings) ⇒ ApplicationTokenProvider
Creates and initialize new instance of the ApplicationTokenProvider class.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ms_rest_azure/credentials/application_token_provider.rb', line 49 def initialize(tenant_id, client_id, client_secret, settings = ActiveDirectoryServiceSettings.get_azure_settings) fail ArgumentError, 'Tenant id cannot be nil' if tenant_id.nil? fail ArgumentError, 'Client id cannot be nil' if client_id.nil? fail ArgumentError, 'Client secret key cannot be nil' if client_secret.nil? fail ArgumentError, 'Azure AD settings cannot be nil' if settings.nil? @tenant_id = tenant_id @client_id = client_id @client_secret = client_secret @settings = settings @expiration_threshold = 5 * 60 end |
Instance Method Details
#get_authentication_header ⇒ String
Returns the string value which needs to be attached to HTTP request header in order to be authorized.
68 69 70 71 |
# File 'lib/ms_rest_azure/credentials/application_token_provider.rb', line 68 def get_authentication_header acquire_token if token_expired "#{token_type} #{token}" end |