Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a token to connect to a container #16792

Closed
kowiste opened this issue Jan 11, 2022 · 5 comments
Closed

Use a token to connect to a container #16792

kowiste opened this issue Jan 11, 2022 · 5 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage Storage Service (Queues, Blobs, Files)

Comments

@kowiste
Copy link

kowiste commented Jan 11, 2022

I'm trying to connect to a blobstorage using a token that I get like this:

cred, err := azidentity.NewClientSecretCredential(tenantID, clientID, clientSecret, nil)

I can use this function and see that return me a token:

policy := policy.TokenRequestOptions{ Scopes: []string{clientID + "/.default"}, } resp, err := ced.GetToken(context.Background(), policy)

In the program I call to this function

conn, err := azblob.NewContainerClient(containerURL, cred, nil)

When I try to write using this connection to the container I have the follow error:

===== RESPONSE ERROR (ErrorCode=AuthorizationPermissionMismatch) ===== Description=This request is not authorized to perform this operation using this permission. RequestId:19f268a9-301e-0027-28c1-06fd6a000000 Time:2022-01-11T08:03:07.6493384Z, Details: (none)
The devops tell me that the problem is I have to get the token using scopes, but what I see in NewContainerClient is that use this constant:

const tokenScope untyped string = "https://storage.azure.com/.default"

There is any way to pass scopes to NewContainerClient or I should use other way?

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jan 11, 2022
@RickWinter RickWinter added Azure.Identity Client This issue points to a problem in the data-plane of the library. labels Jan 11, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Jan 11, 2022
@chlowell
Copy link
Member

Scopes are handled internally by clients, and https://storage.azure.com/.default is the only one for Azure Storage. I'm not so familiar with Storage (I'll assign someone who is) but that error suggests the problem is with authorization, that is to say the service principal isn't authorized to perform the operation.

@chlowell chlowell added Storage Storage Service (Queues, Blobs, Files) and removed Azure.Identity labels Jan 11, 2022
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jan 11, 2022
@zezha-msft
Copy link

@kowiste could you please make sure that you've assigned the right permissions to the service principal on the account? e.g. Storage Blob Data Contributor

@chlowell chlowell added needs-author-feedback Workflow: More information is needed from author to address the issue. and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Jan 13, 2022
@kowiste
Copy link
Author

kowiste commented Jan 17, 2022

Thanks @zezha-msft, I just check with the dev ops, we change the role for the app to contributor but it still give the same error. I can have a token with azidentity.NewClientSecretCredential . I use it in azblob.NewContainerClient and with the client when try to write I have the same error.

@ghost ghost added needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team and removed needs-author-feedback Workflow: More information is needed from author to address the issue. labels Jan 17, 2022
@zezha-msft
Copy link

@kowiste I don't think the Contributor is the correct one. Please try "Storage Blob Data Contributor" instead.

Useful reading: https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-app?tabs=dotnet#assign-a-role-to-an-azure-ad-security-principal

@chlowell chlowell added needs-author-feedback Workflow: More information is needed from author to address the issue. and removed needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Feb 16, 2022
@ghost
Copy link

ghost commented Feb 23, 2022

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label Feb 23, 2022
@ghost ghost closed this as completed Mar 9, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

No branches or pull requests

4 participants