steep-balloon-41261
07/28/2023, 3:15 AMacoustic-engineer-41666
07/28/2023, 3:16 AMmagnificent-art-43333
07/28/2023, 3:16 AMacoustic-engineer-41666
07/28/2023, 3:17 AMroomCreate: false in the access token grantsacoustic-engineer-41666
07/28/2023, 3:17 AMthankful-rain-7893
07/28/2023, 3:19 AMgetMonitorToken ({ roomId } = {}) {
const at = new AccessToken(key, secret, { identity: this.userId })
// <https://docs.livekit.io/concepts/authentication/#video-grant>
at.addGrant({
room: roomId,
roomCreate: false,
roomJoin: true,
canPublish: false,
canSubscribe: true,
canPublishData: false,
roomRecord: false,
})
const token = at.toJwt()
return token
},thankful-rain-7893
07/28/2023, 3:20 AMacoustic-engineer-41666
07/28/2023, 3:21 AMthankful-rain-7893
07/28/2023, 3:57 AMacoustic-engineer-41666
07/28/2023, 3:58 AMthankful-rain-7893
07/28/2023, 4:13 AMthankful-rain-7893
07/28/2023, 4:30 AMthankful-rain-7893
07/28/2023, 4:31 AMconst url = '<wss://live-dev-k5mhurx4.livekit.cloud>'
const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ2aWRlbyI6eyJyb29tSm9pbiI6dHJ1ZSwicm9vbSI6Im5hbWUtb2Ytcm9vbSIsInJvb21DcmVhdGUiOmZhbHNlLCJjYW5QdWJsaXNoIjpmYWxzZSwiY2FuU3Vic2NyaWJlIjp0cnVlLCJjYW5QdWJsaXNoRGF0YSI6ZmFsc2UsInJvb21SZWNvcmQiOmZhbHNlfSwiaWF0IjoxNjkwNTE4MzYzLCJuYmYiOjE2OTA1MTgzNjMsImV4cCI6MTY5MDUzOTk2MywiaXNzIjoiQVBJRVFXaDg0aXM0Y1I4Iiwic3ViIjoidXNlci1uYW1lIiwianRpIjoidXNlci1uYW1lIn0.yX9Y6hB8vtwoXCRXHbTEUQ1PwPbQr4yU7O92NBiPuSY'
const connect = function () {
const room = new LivekitClient.Room()
room.on(LivekitClient.RoomEvent.ConnectionStateChanged, console.log)
room.prepareConnection(url)
room.connect(url, token)
}
connect()
server grant
const { AccessToken } = require('livekit-server-sdk')
const roomName = 'name-of-room'
const participantName = 'user-name'
const at = new AccessToken('APIEQWh84is4cR8', '67nYbTwKafZwOVf9CLtzL1VQ27nCeox6EmXrsuGJ0dgB', {
identity: participantName,
})
at.addGrant({
roomJoin: true,
room: roomName,
roomCreate: false,
roomJoin: true,
canPublish: false,
canSubscribe: true,
canPublishData: false,
roomRecord: false,
})
const token = at.toJwt()
console.log('access token', token)dry-elephant-14928
07/28/2023, 5:42 AMroomCreate is for users that are calling CreateRoom API explicitlydry-elephant-14928
07/28/2023, 5:43 AMautoCreate is allowed, users do not require roomCreate for the room to be automatically createdpolite-kilobyte-67570
07/28/2023, 7:10 AMSettings/Project where you can disable the checkmark for auto room creation. It is enabled by default.