The AccessToken Entity

Access Token

Catalytic.SDK.Entities.AccessToken

The AccessToken class represents authorization to use the SDK as a specific, authenticated user. See Authentication for more details and examples.

Summary of Properties and Methods

Static Properties

NameTypeDescription
DefaultAccessTokenAttempt to load and return an Access Token from the default env var or file location
HasDefaultboolCheck whether or not default a Access Token is configured
DefaultAccessTokenDirectorystringGets the default path for saved Access Token files. Resolves to $HOME/.catalytic/tokens or equivalent

Static Methods

NameReturn TypeDescription
FromFileAccessTokenAttempt to load and return an Access Token from a file
FromStringAccessTokenDeserializes an Access Token from a serialized Access Token string
FromEnvAccessTokenDeserialize an Access Token from the CATALYTIC_TOKEN
env var
ListAccessTokensDictionary
<string, AccessToken>
Lists all Access Tokens stored as files in the given path
or in the default path
DeleteAccessTokenFilevoidDelete an Access Token file

[

Instance Properties

NameTypeDescription
IdGuidThe unique ID of the AccessToken
NamestringThe descriptive name of the AccessToken
TokenstringThe serialized AccessToken string
DomainstringThe hostname of the Catalytic team to which this AccessToken grants access
TypeAccessTokenTypeWill always be User for user AccessTokens
SecretstringThe hex-encoded bytes of the secret key for this AccessToken
EnvironmentstringAn internal reference to the Catalytic environment, typically v1
ReferenceNamestringRead-only alias for Id, represented as a string. Used when
a Workflow is added to an ReferenceableCollection<T>

Instance Methods

NameReturn TypeDescription
SaveToFilevoidSaves the AccessToken to a file

Constructors

AccessToken instances should not be created directly via the constructor. Instead they should be deserialized with one of the FromFile, FromString or FromEnv static methods, or from one of the Create an Access Token methods on the AccessTokens service client.

The FromFile Static Method

Load an Access Token by name from the default Access Token directory, a given directory or a specific file location. The default directory is AccessToken.DefaultAccessTokensDirectory, which will be $HOME/.catalytic/tokens or the equivalent depending on the OS.

Method Signature

static AccessToken FromFile(string accessTokenName, DirectoryInfo accessTokensDirectory = null)
ParameterTypeDescription
accessTokenNamestringThe name of the Access Token file to load
accessTokenDirectoryDirectoryInfoOptional Access Tokens directory, defaults to
AccessToken.DefaultAccessTokensDirectory
returnsAccessTokenThe deserialized Access Token
static AccessToken FromFile(FileInfo accessTokenFile)
ParameterTypeDescription
accessTokenFileFileInfoA reference to the file to load Access Token from
returnsAccessTokenThe deserialized AccessToken

The FromToken Static Method

Deserializes an Access Token from a token string. Token strings can be copied when a new User Access Token is first created in the Catalytic Web App. See Authentication for details.

This method can be used to instantiate an Access Token from a token string you have stored somewhere like Azure Key Vault, Hashicorp Vault or AWS Secrets Manager.

Method Signature

static AccessToken FromString(string serializedAccessToken)
ParameterTypeDescription
serializedAccessTokenstringThe serialized Access Token
returnsAccessTokenThe deserialized Access Token

The FromEnv Static Method

Deserializes an Access Token from a token string stored in the CATALYTIC_TOKEN env var.

Method Signature

static AccessToken FromEnv()
ParameterTypeDescription
returnsAccessTokenThe deserialized Access Token

The ListAccessTokens Static Method

Gets all Access Tokens stored in a given directory, or in the default Access Token directory if none is specified. The default directory is AccessToken.DefaultAccessTokensDirectory, which will be $HOME/.catalytic/tokens or the equivalent depending on the OS.

Method Signature

static Dictionary<string, AccessToken> ListAccessTokens(DirectoryInfo accessTokensDirectory = null)
ParameterTypeDescription
accessTokensDirectoryDirectoryInfoOptional Access Token directory, defaults to
AccessToken.DefaultAccessTokensDirectory
returnsDictionary<string, AccessToken>All the deserialized Access Tokens in the given (or default) directory, by name.

The DeleteAccessTokenFile Static Method

Deletes saved Access Token.

Method Signature

static void DeleteAccessTokenFile(string accessTokenName, DirectoryInfo accessTokensDirectory = null)
ParameterTypeDescription
accessTokenNamestringThe name of the Access Token file to delete
accessTokensDirectoryDirectoryInfoOptional Access Tokens directory, defaults to
AccessToken.DefaultAccessTokensDirectory

The SaveToFile Instance Method

Saves an Access Token to a file. Throws AccessTokenNameConflictException if the file already exists.

Method Signature

void SaveToFile(string accessTokenName = "default", DirectoryInfo accessTokensDirectory = null)
ParameterTypeDescription
accessTokenNamestringThe name of the Access Token file to create
accessTokensDirectoryDirectoryInfoOptional Access Tokens directory, defaults to
AccessToken.DefaultAccessTokensDirectory
void SaveToFile(FileInfo accessTokenFile)
ParameterTypeDescription
accessTokenFileFileInfoThe Access Token file to create