Reputation: 11
I have to develop an app that uploads local files to the ACC (without file size and name length restrictions). This app has already been developed before but we have no documentation or access to the source code.
I'm supposed to finish the app within a month.
I already had 2 meetings with devs from Autodesk and they told me to use the Data Management API, and also use some parts of the Simple Viewer and Hubs Browser tutorials. I have copied the whole Application Setup and Authentication parts from the Hubs Browser (in order to use the 3-legged authentication) and the "Data Management" part from the Data & Derivatives section of the Simple Viewer.
I've also changed the APS.Auth code, since I won't need a public token. Right now it looks like this:
using System;
using System.Threading.Tasks;
using Autodesk.Forge;
public partial class APS
{
public string GetAuthorizationURL()
{
return new ThreeLeggedApi().Authorize(_clientId, "code", _callbackUri, InternalTokenScopes);
}
public async Task<Tokens> GenerateTokens(string code)
{
dynamic internalAuth = await new ThreeLeggedApi().GettokenAsync(_clientId, _clientSecret, "authorization_code", code, _callbackUri);
//dynamic publicAuth = await new ThreeLeggedApi().RefreshtokenAsync(_clientId, _clientSecret, "refresh_token", internalAuth.refresh_token, PublicTokenScopes);
return new Tokens
{
//PublicToken = publicAuth.access_token,
InternalToken = internalAuth.access_token,
RefreshToken = internalAuth.refresh_token, // MUDEI ESSA LINHA DE PUBLIC AUTH PARA INTERNAL AUTH
ExpiresAt = DateTime.Now.ToUniversalTime().AddSeconds(internalAuth.expires_in)
};
}
public async Task<Tokens> RefreshTokens(Tokens tokens)
{
dynamic internalAuth = await new ThreeLeggedApi().RefreshtokenAsync(_clientId, _clientSecret, "refresh_token", tokens.RefreshToken, InternalTokenScopes);
//dynamic publicAuth = await new ThreeLeggedApi().RefreshtokenAsync(_clientId, _clientSecret, "refresh_token", internalAuth.refresh_token, PublicTokenScopes);
return new Tokens
{
//PublicToken = publicAuth.access_token,
InternalToken = internalAuth.access_token,
RefreshToken = internalAuth.refresh_token, // MUDEI ESSA LINHA DE PUBLIC AUTH PARA INTERNAL AUTH
ExpiresAt = DateTime.Now.ToUniversalTime().AddSeconds(internalAuth.expires_in)
};
}
public async Task<dynamic> GetUserProfile(Tokens tokens)
{
var api = new UserProfileApi();
api.Configuration.AccessToken = tokens.InternalToken;
dynamic profile = await api.GetUserProfileAsync();
return profile;
}
}
I'm not sure where to go from here,if anyone from Autodesk could help me through this project, that would be very helpful, I have pretty much no prior experience with the APS.
Also, I'm not actually going to implement a Viewer, I'm only using that tutorial to help me with the 3-legged auth.
Upvotes: 1
Views: 119
Reputation: 688
To address your workflows, I suggest you explore the new official SDK currently in Beta, as this is the way to go future-wise.
Since we don't have samples using this new SDK, you can refer to the new methods for uploading and downloading exposed at https://aps.autodesk.com/blog/direct-s3-upload-and-download-sdks
Since you need to address upload to ACC, there are some extra steps required:
You'll need to define the logic for the first step, and from there, you'll have paths like Hub A/Project A/Project Files/Subfolder A
With these IDs (hub, project, and folders), you can address the steps from item 2.
You can find one implementation of ACC upload at https://github.com/autodesk-platform-services/aps-directToS3/blob/net6.0/test/upload-to-docs.cs
Just note that instead of using the BinarytransferClient.UploadToBucket method, you'll use the snippet shared in the blog post.
I suggest you start with a console app focusing on the core of your workflow and then implement the UI ;)
Upvotes: 0