Files
wehub-resource-sync ead81af521
Deploy to GitHub Pages / deploy (push) Failing after 0s
CI / go (push) Has been cancelled
CI / build (darwin, macos-14) (push) Has been cancelled
CI / build (windows, windows-2025) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:13 +08:00

30 lines
945 B
Go

package ytmusic
import (
"math/rand/v2"
)
// fallbackCredentials is a pool of Google Cloud OAuth2 Desktop app credentials
// used when the user has not configured their own client_id/client_secret.
// A random entry is selected each session to spread quota load across projects.
//
// These are Desktop-type OAuth2 credentials. Google allows embedding them in
// open-source desktop apps — the user still authenticates via their own Google
// account, so the credentials alone grant no access.
type oauthCreds struct {
ClientID string
ClientSecret string
}
var fallbackCredentials []oauthCreds
// FallbackCredentials returns a random credential pair from the built-in pool,
// or empty strings if the pool is empty.
func FallbackCredentials() (clientID, clientSecret string) {
if len(fallbackCredentials) == 0 {
return "", ""
}
c := fallbackCredentials[rand.IntN(len(fallbackCredentials))]
return c.ClientID, c.ClientSecret
}