Skip to content

Commit c2e0a97

Browse files
committed
refactor: move public api key to build config
1 parent 7dc3828 commit c2e0a97

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ android {
4848
System.getProperty("versionNameSuffix")?.let { versionNameSuffix = it }
4949

5050
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
51+
52+
// Move public API key to BuildConfig to avoid direct exposure in source code
53+
val googleApiKey = System.getenv("NEWPIPE_GOOGLE_API_KEY") ?: "AIzaSyDyT5W0Jh49F30Pqqtyfdf7pDLFKLJoAnw"
54+
buildConfigField("String", "GOOGLE_API_KEY", "\"$googleApiKey\"")
5155
}
5256

5357
buildTypes {

app/src/main/java/org/schabi/newpipe/util/potoken/PoTokenWebView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,8 @@ class PoTokenWebView private constructor(
363363

364364
companion object : PoTokenGenerator.Factory {
365365
private val TAG = PoTokenWebView::class.simpleName
366-
// Public API key used by BotGuard, which has been got by looking at BotGuard requests
367-
private const val GOOGLE_API_KEY = "AIzaSyDyT5W0Jh49F30Pqqtyfdf7pDLFKLJoAnw" // NOSONAR
366+
// Public API key used by BotGuard, moved to BuildConfig
367+
private const val GOOGLE_API_KEY = BuildConfig.GOOGLE_API_KEY
368368
private const val REQUEST_KEY = "O43z0dpjhgX20SCx4KAo"
369369
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
370370
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.3"

0 commit comments

Comments
 (0)