Skip to content

Latest commit

 

History

History
60 lines (42 loc) · 1.23 KB

File metadata and controls

60 lines (42 loc) · 1.23 KB

Agora Token Generator Kotlin

This project provides the implementation of Agora AccessToken2 in Kotlin.

Project Structure

  • 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.

How to use

Build

You can build the project using Gradle:

./gradlew build

Run Sample

To 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)

Run Tests

./gradlew test

Example Usage

import 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")