refactor: move public api key to build config

This commit is contained in:
RinCodeForge927 2026-01-13 20:59:53 +07:00
parent 77d62deeed
commit 59e01e38fe
2 changed files with 6 additions and 2 deletions

View File

@ -48,6 +48,10 @@ android {
System.getProperty("versionNameSuffix")?.let { versionNameSuffix = it }
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
// Move public API key to BuildConfig to avoid direct exposure in source code
val googleApiKey = System.getenv("NEWPIPE_GOOGLE_API_KEY") ?: "AIzaSyDyT5W0Jh49F30Pqqtyfdf7pDLFKLJoAnw"
buildConfigField("String", "GOOGLE_API_KEY", "\"$googleApiKey\"")
}
buildTypes {

View File

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