Table of Contents

Class AuthenticationClientHelper

Namespace
Autodesk.Authentication.Helpers
Assembly
Autodesk.Authentication.dll

Helper class for the Autodesk Authentication SDK

public class AuthenticationClientHelper
Inheritance
AuthenticationClientHelper
Inherited Members

Properties

Api

The Authentication API client

public BaseAuthenticationClient Api { get; init; }

Property Value

BaseAuthenticationClient

Methods

CreateAuthenticationUrl(string, string, IEnumerable<AuthenticationScope>, string, string, bool)

Create the url for reaching the Autodesk login page (3legged Auth)

public static string CreateAuthenticationUrl(string clientId, string redirectUri, IEnumerable<AuthenticationScope> scope, string nonce = "", string state = "", bool forceLogin = false)

Parameters

clientId string

Autodesk App Id

redirectUri string

Callback url

scope IEnumerable<AuthenticationScope>

Token scope

nonce string

Optional, except if scope is 'OpenId'

state string
forceLogin bool

Returns

string

Url for the Autodesk login page

CreateAuthorizationString(string, string)

Combine client id and client secret to create a base64 encoded string

public static string CreateAuthorizationString(string clientId, string clientSecret)

Parameters

clientId string

Autodesk App Id

clientSecret string

Autodesk App Secret

Returns

string

'{clientId}:{clientSecret}' in base64 encoded string

CreatePKCE_authenticationUrl(string, string, IEnumerable<AuthenticationScope>, string, string, string, bool)

Create the url for reaching the Autodesk login page with PKCE authentication

public static string CreatePKCE_authenticationUrl(string clientId, string redirectUri, IEnumerable<AuthenticationScope> scope, string codeChallenge, string nonce = "", string state = "", bool forceLogin = false)

Parameters

clientId string

Autodesk App Id

redirectUri string

Callback url

scope IEnumerable<AuthenticationScope>

Token scope

codeChallenge string
nonce string

Optional, except if scope is 'OpenId'

state string

Optional.

forceLogin bool

Default:False. If 'true' ignore the current session and force the login again

Returns

string

Url for Autodesk PKCE authentication

CreateScopeString(IEnumerable<AuthenticationScope>)

Convert a list of scopes to a string

public static string CreateScopeString(IEnumerable<AuthenticationScope> scopes)

Parameters

scopes IEnumerable<AuthenticationScope>

List of scopes

Returns

string

Scopes separated with spaces

CreateScopeString(IEnumerable<string>)

public static string CreateScopeString(IEnumerable<string> scopes)

Parameters

scopes IEnumerable<string>

Returns

string

CreateTwoLeggedAutoRefreshToken(string, string, IEnumerable<AuthenticationScope>, ITokenStore)

Create an auto refreshing 2 legged token

[Obsolete("Use CreateTwoLeggedAutoRefreshToken(string clientId, string clientSecret, IEnumerable<string> scopes, ITokenStore authTokenStore) instead")]
public Func<Task<string>> CreateTwoLeggedAutoRefreshToken(string clientId, string clientSecret, IEnumerable<AuthenticationScope> scopes, ITokenStore authTokenStore)

Parameters

clientId string
clientSecret string
scopes IEnumerable<AuthenticationScope>
authTokenStore ITokenStore

Used for storing the generated token. The token will be reused until it expires. At that point it will be regenerated

Returns

Func<Task<string>>

Function returning a 2L AccessToken

CreateTwoLeggedAutoRefreshToken(string, string, IEnumerable<string>, ITokenStore)

Create an auto refreshing 2 legged token

public Func<Task<string>> CreateTwoLeggedAutoRefreshToken(string clientId, string clientSecret, IEnumerable<string> scopes, ITokenStore authTokenStore)

Parameters

clientId string
clientSecret string
scopes IEnumerable<string>
authTokenStore ITokenStore

Used for storing the generated token. The token will be reused until it expires. At that point it will be regenerated

Returns

Func<Task<string>>

Function returning a 2L AccessToken

ExtractCodeFromUrl(string)

Extract the code from the callback url

public static string? ExtractCodeFromUrl(string url)

Parameters

url string

Callback url from Autodesk Authentication

Returns

string

Code

GetTwoLeggedToken(string, string, IEnumerable<AuthenticationScope>)

Create a 2 legged token

[Obsolete("Use GetTwoLeggedToken(string clientId, string clientSecret, IEnumerable<string> scopes) instead")]
public Task<AuthTokenExtended> GetTwoLeggedToken(string clientId, string clientSecret, IEnumerable<AuthenticationScope> scopes)

Parameters

clientId string

Autodesk App Id

clientSecret string

Autodesk App Secret

scopes IEnumerable<AuthenticationScope>

List of scopes

Returns

Task<AuthTokenExtended>

Fresh 2 legged token with expiration date calculated

GetTwoLeggedToken(string, string, IEnumerable<string>)

Create a 2 legged token

public Task<AuthTokenExtended> GetTwoLeggedToken(string clientId, string clientSecret, IEnumerable<string> scopes)

Parameters

clientId string

Autodesk App Id

clientSecret string

Autodesk App Secret

scopes IEnumerable<string>

List of scopes

Returns

Task<AuthTokenExtended>

Fresh 2 legged token with expiration date calculated

GetUserInfoAsync(string)

Get the User info.

public Task<UserInfo?> GetUserInfoAsync(string threeLeggedToken)

Parameters

threeLeggedToken string

3L Access token

Returns

Task<UserInfo>

User info

IsValidToken(AuthTokenExtended?)

Check if a token is valid

public static bool IsValidToken(AuthTokenExtended? authToken)

Parameters

authToken AuthTokenExtended

Token to check

Returns

bool

'True' if valid token

RefreshThreeLeggedToken(string, string, string, IEnumerable<AuthenticationScope>?)

Refresh a 3 legged token

public Task<AuthTokenExtended> RefreshThreeLeggedToken(string clientId, string clientSecret, string refreshToken, IEnumerable<AuthenticationScope>? scopes = null)

Parameters

clientId string

Autodesk App Id

clientSecret string

Autodesk App secret

refreshToken string

Refresh token returned by the previous authentication

scopes IEnumerable<AuthenticationScope>

New scope. You can only reduce the initial scope

Returns

Task<AuthTokenExtended>

Fresh 3 legged token

Exceptions

InvalidOperationException