Share via

Canot Authen by username/password via BasicAuthenticationCredential Java

Duy Nguyen Khanh 21 Reputation points
2021-05-18T03:13:57.943+00:00

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("******@gooddata.com","password");
    blobServiceClient = new BlobServiceClientBuilder()
            .credential(basicAuthenticationCredential)
            .endpoint("https://msfdev.blob.core.windows.net")
            .buildClient();
    blobServiceClient.getProperties();
Azure Blob Storage
Azure Blob Storage

An Azure service that stores unstructured data in the cloud as blobs.

0 comments No comments

Answer accepted by question author

Anonymous
2021-05-18T21:45:06.213+00:00

@Duy Nguyen Khanh
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.

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Duy Nguyen Khanh 21 Reputation points
    2021-07-05T07:01:46.59+00:00

    Thank you for the answer. @Anonymous

    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://learn.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();

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.