This project provides the implementation of Agora AccessToken2 in Kotlin.
src/main/kotlin: Core logic for generating tokens.src/sample/kotlin: Sample usage of the token builders.src/test/kotlin: Unit tests for the implementation.
You can build the project using Gradle:
./gradlew buildTo run the sample, you need to set the following environment variables:
AGORA_APP_ID: Your Agora App ID.AGORA_APP_CERTIFICATE: Your Agora App Certificate.
Then run:
./gradlew runSample(Note: You might need to add a runSample task to your build.gradle.kts if you want to run it via Gradle)
./gradlew testimport io.agora.media.RtcTokenBuilder2
val appId = "YOUR_APP_ID"
val appCertificate = "YOUR_APP_CERTIFICATE"
val channelName = "YOUR_CHANNEL_NAME"
val uid = 123
val role = RtcTokenBuilder2.Role.ROLE_PUBLISHER
val tokenExpire = 3600
val privilegeExpire = 3600
val tokenBuilder = RtcTokenBuilder2()
val token = tokenBuilder.buildTokenWithUid(
appId, appCertificate, channelName, uid, role,
tokenExpire, privilegeExpire
)
println("Token: $token")