PowerSync allows generating temporary development tokens for authentication. This is useful for developers who want to get up and running quickly, without a full custom auth implementation. This may also be used to generate a token for a specific user to debug issues.
Enable setting: The “Enable development tokens” setting must be set on the PowerSync instance. It can be set in the instance’s config (In the PowerSync dashboard: Edit instance -> Client Auth).
Generate token: Call the “Generate development token” action for your instance. In the PowerSync dashboard, this can be done via the command palette (CMD+SHIFT+P / SHIFT+SHIFT), or by selecting it from an instance’s options (right-click on an instance for options).
Enter token subject / user ID: This is the ID of the user you want to authenticate and is used in sync rules as request.user_id() (previously, token_parameters.user_id)
Copy the generated token. Note that these tokens expire after 12 hours.
For self-hosted local development, the powersync-service test client contains a script to generate a development token, given a .yaml config file with an HS256 key. Run the following command:
To use the temporary development token, update the fetchCredentials() function in your backend connector to return the generated token (see Integrate with your Backend for more information).Example: