Azure / azure-storage-android

Microsoft Azure Storage Library for Android
Apache License 2.0
81 stars 48 forks source link

CloudBlobContainer authentication error when repeating listBlobs() #82

Open avinabmalla opened 4 years ago

avinabmalla commented 4 years ago

The method CloudBlobContainer.listBlobs() works when called the first time after installing the app, but will not work again and throw the following MAC signature invalid error.

The MAC signature found in the HTTP request 'xxxxxxxxxx' is not the same as any computed signature. Server used following string to sign: 'GET

Mon, 24 Aug 2020 14:39:19 GMT

x-ms-client-request-id:5830d2ce-c356-40c0-a9a1-cecd66921336 x-ms-date:Mon, 24 Aug 2020 16:48:29 GMT x-ms-version:2017-04-17 /myaccoun t/mycontainer comp:list delimiter:/ restype:container'.

The listBlobs() method will only work for the same container again after the app's cache is cleared.

I am using the following code to list blobs (Kotlin)

` val storageAccount = CloudStorageAccount.parse(connectionString) val blobClient = storageAccount.createCloudBlobClient() val container = blobClient.getContainerReference(name) val blobs = container.listBlobs()

val blobNames: ArrayList = ArrayList() for (blob in blobs) { blobNames.add((blob as CloudBlockBlob).name) } `

avinabmalla commented 4 years ago

Looks like the old requests are being cached in the com.microsoft.identity.http-cache folder in the app's cache directory. I need to delete the folder every time I run listBlobs().