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.
permission
is theHttpClient.Permission
required to make an HTTP request.token
is 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.
tokens
are all of the tokens for the user. This only specifies the tokenname
andid
and 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.
permission
is theHttpClient.Permission
required to make an HTTP request.token
is the token used to identify the user who you want to create a new token for.createdTokenName
is 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.
name
is the name of the created token.id
is the unique id for the created token.token
is 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.
permission
is theHttpClient.Permission
required to make an HTTP request.token
is 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.
exp
is 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.
permission
is theHttpClient.Permission
required to make an HTTP request.token
is the token used to identify the user whose token you want to revoke.tokenNameToRevoke
is the name of the token you want to revoke.
type alias RevokeResult =
{ tokenName : String }
The result of revoking a token.
tokenName
is the name of the revoked token. This should match the name given to therevoke
function.
revoke :
RevokeArgs
-> Task (Error RevokeResult)
(Response RevokeResult)
Revoke a token.