home / docs / sections

sections: internals:datasette-create-token

This data as json

id page ref title content breadcrumbs references
internals:datasette-create-token internals datasette-create-token await .create_token(actor_id, expires_after=None, restrictions=None, handler=None) actor_id - string The ID of the actor to create a token for. expires_after - int, optional The number of seconds after which the token should expire. restrictions - TokenRestrictions , optional A TokenRestrictions object limiting which actions the token can perform. handler - string, optional The name of a specific token handler to use. If omitted, the first registered handler is used. See register_token_handler(datasette) . This is an async method that returns an API token string which can be used to authenticate requests to the Datasette API. The default SignedTokenHandler returns tokens of the format dstok_... . All tokens must have an actor_id string indicating the ID of the actor which the token will act on behalf of. Tokens default to lasting forever, but can be set to expire after a given number of seconds using the expires_after argument. The following code creates a token for user1 that will expire after an hour: token = await datasette.create_token( actor_id="user1", expires_after=3600, ) ["Internals for plugins", "Datasette class"] []
Powered by Datasette · Queries took 3.722ms