0

I've been trying to get a 3-legged authentication to work. I believe I've been to all resources Autodesk has online but unfortunately they all show different things and despite trying to piece it all together, I'm stuck again.

Below is all the material I've been through.

APS Tutorials https://aps.autodesk.com/en/docs/oauth/v2/tutorials/get-3-legged-token/ https://get-started.aps.autodesk.com/tutorials/hubs-browser/auth

Git SDK https://github.com/autodesk-platform-services/aps-sdk-net

.NET Reference Guide https://aps.autodesk.com/en/docs/oauth/v2/reference/dot-net-sdk/

Git APS Hubs sample code https://github.com/autodesk-platform-services/aps-hubs-recursive-extraction

I'm stuck at two points at the moment:

  1. I'm successfully getting a URL string from the Authorize() method however, my browser is not opening the URL automatically despite all the documentation saying it should. I'm currently calling Process.Start() to open that URL but it feels wrong.
  2. How do I get the authorisation code from the callback URL? All documentation I found only mentions the step after I have the code but it doesn't show how I can get it despite looking into lots of sample code Autodesk has online.

Sample code below.

Documentation summary snapshot

SDKManager sdkManager = SdkManagerBuilder
.Create() // Creates SDK Manager Builder itself.
.Build();

var authClient = new AuthenticationClient(sdkManager);

var authURL = authClient.Authorize(clientId, ResponseType.Code, callbackUri,
                                 new List<Scopes> { Scopes.DataRead, Scopes.ViewablesRead });

Process.Start(new ProcessStartInfo(authURL) { UseShellExecute = true });
1
  • To get the code, the authorization server, typically returns a HTML page that contains a HTML form,that then is automatically "submitted" using JavaScript, back to your redirectUri. The auth server, can't directly call the redirectUri, it has to tell the browser to redirect to the redirectUri. Commented Aug 11 at 6:18

1 Answer 1

0

Before diving into the solution, could you share how you're currently implementing the authentication flow? From your use of Process.Start, it seems you're working on a desktop application. Have you tried running the sample web app from the APS tutorials: https://github.com/autodesk-platform-services/aps-hubs-browser-dotnet

In that tutorial, there's a section that explains how the API controller handles authentication: https://get-started.aps.autodesk.com/tutorials/hubs-browser/auth#server-endpoints

  • The GET /login endpoint redirects the user to the APS authorization page.

  • The GET /callback endpoint is where APS sends the authorization code after the user grants access.

This code is typically returned via a browser redirect to your redirectUri. The APS authorization server can't directly call your app—it sends a response that includes a form with JavaScript that automatically redirects the browser to your callback URL, appending the code as a query parameter.

If you're using Process.Start to open the authorization URL, make sure your app is also set up to listen for incoming requests on the callback URI. For desktop apps, this often means running a local HTTP listener (e.g., using HttpListener in .NET) that waits for the redirect and extracts the code from the query string.

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

Comments

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.