Skip to content

Commit 8472e7c

Browse files
committed
Add overload for TokenSource.fromEndpoint that accepts a string for the url
1 parent c07d159 commit 8472e7c

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.changeset/hip-dingos-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"client-sdk-android": patch
3+
---
4+
5+
Add overload for TokenSource.fromEndpoint that accepts a string for the url

livekit-android-sdk/src/main/java/io/livekit/android/token/EndpointTokenSource.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 LiveKit, Inc.
2+
* Copyright 2025-2026 LiveKit, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,13 @@ internal class EndpointTokenSourceImpl(
3636
override val url: URL,
3737
override val method: String,
3838
override val headers: Map<String, String>,
39-
) : EndpointTokenSource
39+
) : EndpointTokenSource {
40+
constructor(
41+
url: String,
42+
method: String,
43+
headers: Map<String, String>,
44+
) : this(URL(url), method, headers)
45+
}
4046

4147
data class SandboxTokenServerOptions(
4248
val baseUrl: String? = null,

livekit-android-sdk/src/main/java/io/livekit/android/token/TokenSource.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 LiveKit, Inc.
2+
* Copyright 2025-2026 LiveKit, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -156,6 +156,20 @@ interface TokenSource {
156156
/**
157157
* Creates a [ConfigurableTokenSource] that fetches from a given [url] using the standard token server format.
158158
*
159+
* @param method the HTTP request method to use. Defaults to POST.
160+
* @see cached
161+
* @see CachingConfigurableTokenSource
162+
*/
163+
fun fromEndpoint(url: String, method: String = "POST", headers: Map<String, String> = emptyMap()): ConfigurableTokenSource = EndpointTokenSourceImpl(
164+
url = url,
165+
method = method,
166+
headers = headers,
167+
)
168+
169+
/**
170+
* Creates a [ConfigurableTokenSource] that fetches from a given [url] using the standard token server format.
171+
*
172+
* @param method the HTTP request method to use. Defaults to POST.
159173
* @see cached
160174
* @see CachingConfigurableTokenSource
161175
*/

0 commit comments

Comments
 (0)