Adsk.Platform.Authentication
                              
                            
                                0.2.1
                            
                        
                    dotnet add package Adsk.Platform.Authentication --version 0.2.1
NuGet\Install-Package Adsk.Platform.Authentication -Version 0.2.1
<PackageReference Include="Adsk.Platform.Authentication" Version="0.2.1" />
<PackageVersion Include="Adsk.Platform.Authentication" Version="0.2.1" />
<PackageReference Include="Adsk.Platform.Authentication" />
paket add Adsk.Platform.Authentication --version 0.2.1
#r "nuget: Adsk.Platform.Authentication, 0.2.1"
#:package Adsk.Platform.Authentication@0.2.1
#addin nuget:?package=Adsk.Platform.Authentication&version=0.2.1
#tool nuget:?package=Adsk.Platform.Authentication&version=0.2.1
Adsk.Platform.Authentication
The Adsk.Platform.DataManagement toolkit provides a set of APIs to interact with the Autodesk Authentication Service.
Documentation
More information can be found here.
Installation
dotnet add package Adsk.Platform.Authentication
Usage
The root object is AuthenticationClient. This object provides access to the Authentication API and the Helpers method.
2 legged authentication
Getting a 2-legged access token is a common scenario. The SDK provides a helper class to simplify:
// Create a new instance of the AuthenticationClient
var authClient = new AuthenticationClient();
// Use helpers to get a 2-legged access token
 AuthTokenExtended authToken = await authClient.Helper.GetTwoLeggedToken(
	APS_CLIENT_ID, 
	APS_CLIENT_SECRET, 
	[AuthenticationScopeDefaults.DataWrite, AuthenticationScopeDefaults.DataRead]);
Here is an example of how to get the hub list:
using Autodesk.DataManagement;
using Autodesk.Authentication;
public async Task<Hubs> GetHub()
{
    var APS_CLIENT_ID="abcd"; // Replace with your client id
    var APS_CLIENT_SECRET="1234"; // Replace with your client secret
    AuthenticationClient authClient = new();
    async Task<string> getAccessToken()
    {
        var token = await authClient.Helper.GetTwoLeggedToken(APS_CLIENT_ID, APS_CLIENT_SECRET, [ AuthenticationScopeDefaults.DataWrite]);
        return token?.AccessToken is null ? throw new InvalidOperationException() : token.AccessToken;
    }
    var DMclient = new DataManagementClient(getAccessToken);
    var hubs = await DMclient.DataMgtApi.Project.V1.Hubs.GetAsync();
    return hubs;
}
3 legged authentication
This SDK depends on AspNet.Security.OAuth.Autodesk that leverages the ASP.NET Core authentication middleware to authenticate users with Autodesk.
- In the - program.csfile, add the authentication middleware:- using Microsoft.AspNetCore.Authentication.Cookies; var builder = WebApplication.CreateBuilder(args); builder.Logging.ClearProviders(); builder.Logging.AddConsole(); builder.Services.AddControllers(); //Define the default authentication scheme // The cookie contains the paths to your sign in and sign out endpoints builder.Services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie(options => { options.LoginPath = "/signin"; options.LogoutPath = "/signout"; }); // Add Autodesk authentication builder.Services.AddAuthentication().AddAutodesk(options => { options.ClientId = builder.Configuration["AUTODESK_CLIENT_ID"] ?? throw new ArgumentException("'AUTODESK_CLIENT_ID' is undefined"); options.ClientSecret = builder.Configuration["AUTODESK_CLIENT_SECRET"] ?? throw new ArgumentException("'AUTODESK_CLIENT_SECRET' is undefined"); options.Scope.Add("data:read"); options.CallbackPath = "/signin-autodesk"; options.SaveTokens = true; // Save the access and refresh tokens that will accessible in the HttpContext }); var app = builder.Build(); app.UseDefaultFiles(); app.UseStaticFiles(); // Configure the HTTP request pipeline. app.UseHttpsRedirection(); app.UseAuthentication(); app.UseAuthorization(); app.MapControllers(); app.MapFallbackToFile("/index.html"); app.Run();
- Create a controller, handling - SignInand- SignOut. In your controller- test.cs:- [ApiController] [Route("api/[controller]")] public class Test() : ControllerBase { private HttpClient _client = new(); [HttpGet("~/signin")] public IActionResult SignIn() { // Instruct the Autodesk authentication middleware to redirect the user agent to the Autodesk login page return Challenge(new AuthenticationProperties { RedirectUri = "/" }, AutodeskAuthenticationDefaults.AuthenticationScheme); } [HttpGet("~/signout")] public IActionResult SignOutCurrentUser() { // Instruct the cookies middleware to delete the local cookie created // when the user agent is redirected from the external identity provider // after a successful authentication flow. return SignOut(new AuthenticationProperties { RedirectUri = "/" }, CookieAuthenticationDefaults.AuthenticationScheme); } [HttpGet("authToken")] [Authorize] //This endpoint is protected by the Autodesk authentication middleware and requires a valid access token (`Authorize` attribute) public async Task<IActionResult> GetTokenAsync() { // The middleware stores the access token in the HttpContext // Ensure that `options.SaveTokens = true` is set in the `AddAutodesk`method in the `program.cs`file (see step 1) var accessToken = await HttpContext.GetTokenAsync(AutodeskAuthenticationDefaults.AuthenticationScheme, "access_token"); if (string.IsNullOrEmpty(accessToken)) { return Unauthorized("No access token available."); } return Ok(accessToken); } }- The - {root}/signinendpoint will redirect the user to the Autodesk login page. Once the user is authenticated, the user will be redirected to the- {root}/endpoint.- Then you can use the - {root}/api/test/authTokenendpoint to get the access token.
Limitations
Get User info
The endpoint to get user info is only available in the Helper. Example:
var authClient = new AuthenticationClient();
var userInfo=authClient.Helper.GetUserInfoAsync("your three legged token");
Advanced
2 legged authentication
The code below shows how to get a 2-legged access token without using the Helper class.
var body = new TokenPostRequestBody()
{
    GrantType = Granttype.Client_credentials,
    Scope = "data:read data:write"
};
var authString = AuthenticationClientHelper.CreateAuthorizationString(APS_CLIENT_ID, APS_CLIENT_SECRET);
AuthToken authToken2 = await authClient.Authentication.V2.Token.PostAsync(body, r =>
{
    r.Headers.Add("Authorization", authString);
});
| Product | Versions Compatible and additional computed target framework versions. | 
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. | 
- 
                                                    net8.0- Adsk.Platform.HttpClient (>= 0.2.1)
- AspNet.Security.OAuth.Autodesk (>= 8.2.0)
- Microsoft.Kiota.Authentication.Azure (>= 1.13.1)
- Microsoft.Kiota.Bundle (>= 1.13.1)
 
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | 
|---|---|---|
| 0.2.1 | 65 | 10/28/2025 | 
| 0.2.0 | 64 | 10/28/2025 | 
| 0.1.18 | 68 | 10/26/2025 | 
| 0.1.17 | 107 | 9/6/2025 | 
| 0.1.16 | 180 | 8/12/2025 | 
| 0.1.15 | 128 | 8/9/2025 | 
| 0.1.14 | 146 | 7/31/2025 | 
| 0.1.13 | 142 | 7/31/2025 | 
| 0.1.12 | 129 | 7/18/2025 | 
| 0.1.11 | 124 | 6/27/2025 | 
| 0.1.10 | 136 | 6/27/2025 | 
| 0.1.9 | 302 | 6/9/2025 | 
| 0.1.8 | 192 | 6/4/2025 | 
| 0.1.7 | 165 | 6/3/2025 | 
| 0.1.6 | 259 | 4/23/2025 | 
| 0.1.5 | 196 | 4/23/2025 | 
| 0.1.4 | 197 | 4/3/2025 | 
| 0.1.3 | 395 | 10/17/2024 | 
| 0.1.2 | 140 | 10/16/2024 | 
| 0.1.1 | 136 | 10/16/2024 | 
| 0.1.0 | 139 | 10/16/2024 | 
| 0.0.16 | 134 | 10/14/2024 | 
| 0.0.15 | 137 | 10/14/2024 | 
| 0.0.14 | 139 | 10/14/2024 | 
| 0.0.13 | 334 | 9/18/2024 | 
| 0.0.12 | 125 | 7/30/2024 | 
| 0.0.11 | 165 | 7/16/2024 | 
| 0.0.10 | 165 | 7/16/2024 | 
| 0.0.9 | 116 | 5/31/2024 | 
| 0.0.8 | 159 | 5/22/2024 | 
| 0.0.7 | 138 | 5/14/2024 | 
| 0.0.6 | 182 | 5/4/2024 | 
| 0.0.5 | 152 | 5/3/2024 | 
| 0.0.4 | 171 | 4/30/2024 | 
| 0.0.3 | 157 | 4/30/2024 |