Turso.Platform.Tokens
Manage tokens in Turso.
This module does not use a Turso.Platform.Connection. The functions here are
for manipulating tokens for a user, who is identified with the access token
passed to each of these functions.
List Tokens
type alias ListArgs =
{ permission : Permission, token : String }
Arguments needed for the list function.
permissionis theHttpClient.Permissionrequired to make an HTTP request.tokenis the token used to identify the user whose tokens you want to list.
type alias ListResult =
{ tokens : Array { name : String, id : String } }
The result of listing all tokens.
tokensare all of the tokens for the user. This only specifies the tokennameandidand does not reveal the token itself.
list :
ListArgs -> Task (Error ListResult) (Response ListResult)
List all Turso platform API tokens belonging to the user.
Create Tokens
type alias CreateArgs =
{ permission : Permission
, token : String
, createdTokenName : String
}
Arguments needed for the create function.
permissionis theHttpClient.Permissionrequired to make an HTTP request.tokenis the token used to identify the user who you want to create a new token for.createdTokenNameis the name you want to give to the created token.
type alias CreateResult =
{ name : String, id : String, token : String }
The result of creating a new Turso platform API token.
nameis the name of the created token.idis the unique id for the created token.tokenis the token itself. This should not be saved unsafely or shared publicly!
create :
CreateArgs
-> Task (Error CreateResult)
(Response CreateResult)
Create a new Turso platform API token.
The resulting token should not be saved unsafely or shared publicly.
Validate Tokens
type alias ValidateArgs =
{ permission : Permission, token : String }
Arguments needed for the validate function.
permissionis theHttpClient.Permissionrequired to make an HTTP request.tokenis the token you want to validate. This must be the actual token and not the token name or id.
type alias ValidateResult =
{ exp : Int }
The result of validating an API token.
expis the expiration time (in unix epoch time) that the token expires.
validate :
ValidateArgs
-> Task (Error ValidateResult)
(Response ValidateResult)
Validate an API token beloning to a user.
Revoke tokens
type alias RevokeArgs =
{ permission : Permission
, token : String
, tokenNameToRevoke : String
}
Arguments needed for the revoke function.
permissionis theHttpClient.Permissionrequired to make an HTTP request.tokenis the token used to identify the user whose token you want to revoke.tokenNameToRevokeis the name of the token you want to revoke.
type alias RevokeResult =
{ tokenName : String }
The result of revoking a token.
tokenNameis the name of the revoked token. This should match the name given to therevokefunction.
revoke :
RevokeArgs
-> Task (Error RevokeResult)
(Response RevokeResult)
Revoke a token.