Connection string
The connection string is used by your server to authenticate with a Y-Sweet server. You can think of it as an API key and URL combined. It typically looks something like this: yss://TOKEN@api.jamsocket.com/...
.
This is a secret key that your app will use to create docs and generate client tokens which give clients the ability to access Y-Sweet documents at a given authorization level (either full
or read-only
).
If you are using Y-Sweet on Jamsocket, getting a connection string is easy:
Create a Y-Sweet service in the Jamsocket dashboard, go to its page, and click “New connection string”. Give it a description and click “Create”, and copy the connection string.
The connection string can then be used to generate a client token with the @y-sweet/sdk
library like so:
import { DocumentManager } from '@y-sweet/sdk'
const docManager = new DocumentManager(process.env.CONNECTION_STRING)
const clientToken = await docManager.getOrCreateDocAndToken(docId, {
authorization: 'full' // may also be 'read-only'
})
Note: a connection string is different than a client token. A client token is used by a client to access a Y-Sweet document at a given authorization level (either full
or read-only
). The connection string, on the other hand, is used by your application’s backend to generate client tokens for clients it has authenticated. The connection string should not be sent to the client and must be kept secret.