jockathon junior
jockathon junior

Reputation: 27

Download revit file from a360 forge bucket

How can I download a file from an Autodesk A360 bucket that I created? The file is a Revit project file and I used 2-legged OAuth for authorization.

Upvotes: 0

Views: 426

Answers (2)

jockathon junior
jockathon junior

Reputation: 27

I don't get a bucket key after attempting to create a bucket in when i change v1 to v2...

see below

public static string GetBucket(string accessToken, string bucketKey, string policy) {

        // (1) Build request 
        var client = new RestClient();
        client.BaseUrl = new System.Uri(baseApiUrl);

        // Set resource/end point
        var request = new RestRequest();
        request.Resource = "oss/v1/buckets";
        request.Method = Method.GET;


        // Add headers  
        request.AddHeader("Authorization", "Bearer " + accessToken);
        request.AddHeader("Content-Type", "application/json"); // MH: skipping this works. 

        // Add JSON body. in simplest form. 
        request.AddJsonBody(new { bucketKey = bucketKey, policy = policy });


        // (2) Execute request and get response
        IRestResponse response = client.Execute(request);
        //TaskDialog.Show("create bucket", response.StatusDescription);

        // Save response. This is to see the response for our learning.
        m_lastResponse = response;

        TaskDialog.Show("response", m_lastResponse.ToString());

        // Get the key = bucket name 
        string key = "";
        if (response.StatusCode == HttpStatusCode.OK)
        {
            JsonDeserializer deserial = new JsonDeserializer();
            OssBucketsResponse bucketsResponse = deserial.Deserialize<OssBucketsResponse>(response);
            key = bucketsResponse.key;
        }




        return key; // the bucket name 
    }

Upvotes: 0

Adam Nagy
Adam Nagy

Reputation: 2125

You need to use 3 legged authentication to access files from A360, because you need the approval of the user whose account you are accessing - the user is the 3rd leg. If you are trying to access files from your own application's private bucket on OSS then you do not need a user's approval because the bucket belongs to your app and not a user.

As a side note, in case of trying to access BIM 360 files (in case that's what you are talking about) using the Data Management API, then for the time being you need to use 2 legged authentication but your app needs to be manually approved by us.

2-legged vs 3-legged authentication is covered by Augusto's webcast: Introduction to oAuth and Data Management API

Upvotes: 1

Related Questions