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
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
stringAutodesk App Id
redirectUri
stringCallback url
scope
IEnumerable<AuthenticationScope>Token scope
nonce
stringOptional, except if scope is 'OpenId'
state
stringforceLogin
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
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
stringAutodesk App Id
redirectUri
stringCallback url
scope
IEnumerable<AuthenticationScope>Token scope
codeChallenge
stringnonce
stringOptional, except if scope is 'OpenId'
state
stringOptional.
forceLogin
boolDefault: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
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
stringclientSecret
stringscopes
IEnumerable<AuthenticationScope>authTokenStore
ITokenStoreUsed for storing the generated token. The token will be reused until it expires. At that point it will be regenerated
Returns
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
stringclientSecret
stringscopes
IEnumerable<string>authTokenStore
ITokenStoreUsed for storing the generated token. The token will be reused until it expires. At that point it will be regenerated
Returns
ExtractCodeFromUrl(string)
Extract the code from the callback url
public static string? ExtractCodeFromUrl(string url)
Parameters
url
stringCallback 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
stringAutodesk App Id
clientSecret
stringAutodesk 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
stringAutodesk App Id
clientSecret
stringAutodesk 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
string3L Access token
Returns
IsValidToken(AuthTokenExtended?)
Check if a token is valid
public static bool IsValidToken(AuthTokenExtended? authToken)
Parameters
authToken
AuthTokenExtendedToken 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
stringAutodesk App Id
clientSecret
stringAutodesk App secret
refreshToken
stringRefresh 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