Azure / Azure/azure-storage-ruby

Azure::Core::Http::HTTPError: AuthenticationFailed (403): Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature

Open
#232 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
88
Forks
177
PR merge metrics
No merged PRs in 30d

Description

hi
am getting

Azure::Core::Http::HTTPError: AuthenticationFailed (403): Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature
error

while am generating access token with managed identity enabled and my production server working perfectly but after sometime it's automatically throwing this error

after restarting the service again it's working like this it's happening repeatedly and
am using code as below

## Access Token

Please refer to the below links for obtaining an access token:
* [Authenticate with Azure Active Directory](https://docs.microsoft.com/en-us/rest/api/storageservices/authenticate-with-azure-active-directory)
* [Getting a MSI access token](https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/tutorial-linux-vm-access-storage#get-an-access-token-and-use-it-to-call-azure-storage)

```ruby
require "azure/storage/common"

access_token =

# Creating an instance of `Azure::Storage::Common::Core::TokenCredential`
token_credential = Azure::Storage::Common::Core::TokenCredential.new access_token
token_signer = Azure::Storage::Common::Core::Auth::TokenSigner.new token_credential
blob_token_client = Azure::Storage::Blob::BlobService.new(storage_account_name: , signer: token_signer)

# Refresh internal is 50 minutes
refresh_interval = 50 * 60
# The user-defined thread that renews the access token
cancelled = false
renew_token = Thread.new do
Thread.stop
while !cancelled
sleep(refresh_interval)

# Renew the access token here

# Update the access token to the credential
token_credential.renew_token
end
end
sleep 0.1 while renew_token.status != 'sleep'
renew_token.run

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.