Introduction

Development tokens are useful for:

  • getting started quickly without implementing full auth config
  • sanity checking your sync rules config (were they applied correctly)
  • temporarily impersonating a specific user to debug specific issues

Use Case

Development tokens can be used either with the

Generate a Development Token

Development tokens can be generated via either

  • PowerSync Cloud, or
  • locally with a self-hosted setup (described in this tutorial)
1

Generate a SharedSecret

To generate a SharedSecret, you can use this Online JWS key generator:

You don’t need to edit the default payload in the Online JWS key generator. You simply need to obtain the generated SharedSecret value.

  • Click Generate JWS Keys
  • Copy the SharedSecret value

Using an online key generator for secrets in a production environment is not recommended.

2

Update powersync.yaml

Update the k value in the jwks keys in your powersync.yaml config file with the SharedSecret value copied in the previous step:

powersync.yaml
# Client (application end user) authentication settings
client_auth:
    # JWKS URIs can be specified here
    jwks_uri: !env PS_JWKS_URL
    jwks:
        keys:
            - kty: 'oct'
              k: 'YOUR_GENERATED_SHARED_SECRET'
              alg: 'HS256'
3

Generate a development token

  1. If you have not done so already, clone the powersync-service repo
  2. Install the dependencies
    • In the project root, run the following commands:
      pnpm install
      pnpm build:packages
      
    • In the test-client directory, run the following commands:
      pnpm build
      
  3. Generate a new token by running the following command in the test-client directory with your updated powersync.yaml config file:
    node dist/bin.js generate-token --config path/to/powersync.yaml --sub test-user
    
    You should see an output similar to the following: