2

I am in the process of learning the Autodesk Forge API. With a simple C# application, I am able to authenticate using the Forge API.

var responseString = await 
"https://developer.api.autodesk.com/authentication/v1/authenticate"
                                .PostUrlEncodedAsync(new
                                {
                                    client_id = Client_ID.Text,
                                    client_secret = Client_Secret.Text,
                                    grant_type = "client_credentials",
                                    scope = "data:read data:write bucket:create bucket:read"
                                })
                                .ReceiveJson();

Though I have explicitly specified the bucket:read scope bucket:read, further call to check a bucket exists fails with error:-

Http code 403 (Forbidden) with the message "Only the bucket creator is allowed to access this API"

When I try to create another bucket with the same name it fails with the:-

Http Code 409 (Conflict) with the message "Bucket already exists"

Can someone please help me on what is missing here?

5
  • The bucket you are trying to access is created by you only? Commented Sep 10, 2017 at 10:28
  • @ChetanRanpariya, No, before creating the bucket, I am calling the API to check if it exists (hoping that it will return an Bucket does not exist) but the error message is different. I looked around the API docs, and it looks like the name should be unique not just in your application but across all applications. Commented Sep 10, 2017 at 10:50
  • So, basically I tried with some long name, after few tries I was able to create a bucket with my unique name. What is confusing is, why they enforce this uniqueness across all applications. Commented Sep 10, 2017 at 10:53
  • 1
    It's just a limitation of the service at the moment unfortunately, so just try to come up with unique names, you can generate GUID-like names pretty easily with any random feature of the language you are using or use your Forge ClientID as prefix or suffix to your bucket name: "bucket1-<YOUR-CLIENT-ID-HERE>". Hope that helps. Commented Sep 11, 2017 at 9:14
  • @PhilippeLeefsma, Thank you. Currently I am using some random names, but will try to follow the convention as suggested Commented Sep 11, 2017 at 10:09

1 Answer 1

2

Yes, the issue is that your bucket key should be globally unique across all application and regions. You can check the doc at https://developer.autodesk.com/en/docs/data/v2/reference/http/buckets-POST/ for the detail, especially for the description of Bucket Key.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I will go with the pattern suggested by "Philippe" to form the unique name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.