question

DuyNguyenKhanh-7847 avatar image
0 Votes"
DuyNguyenKhanh-7847 asked DuyNguyenKhanh-7847 edited

Canot Authen by username/password via BasicAuthenticationCredential Java

Hi im trying to authentication with blob storage via BasicAuthenticationCredential by using username/password.
But i got this error: The access token was missing or malformed
code:

     BasicAuthenticationCredential basicAuthenticationCredential = new BasicAuthenticationCredential("duy.nguyen@gooddata.com","password");
     blobServiceClient = new BlobServiceClientBuilder()
             .credential(basicAuthenticationCredential)
             .endpoint("https://msfdev.blob.core.windows.net")
             .buildClient();
     blobServiceClient.getProperties();
azure-blob-storage
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

deherman-MSFT avatar image
0 Votes"
deherman-MSFT answered

@DuyNguyenKhanh-7847
I have not seen users using BasicAuthenticationCredential for blob storage before. You can refer to the example listed here on how to authenticate with AzureIdentity.

I recommend you also cross-posting this to StackOverflow to engage our developer experts. Let me know if you still need assistance or have further questions.



Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DuyNguyenKhanh-7847 avatar image
0 Votes"
DuyNguyenKhanh-7847 answered DuyNguyenKhanh-7847 edited

Thank you for the answer. @deherman-MSFT

I referred the link share before but I see from document of Azure blob storage. Blob allows us authenticate from Azure AD as well.
https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad?toc=/azure/storage/blobs/toc.json
with security principal (a user, group, or application).
I tried application information it's working fine.
code snipet:

ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientSecret(clientSecret)
.clientId(clientId)
.tenantId(tenantId)
.build();
new BlobServiceClientBuilder()
.credential(clientSecretCredential)
.endpoint(endpoint)
.buildClient()
.getBlobContainerClient(container)
.getProperties();

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.