【问题标题】:Your app contains exposed Google Cloud Platform (GCP) API keys您的应用包含公开的 Google Cloud Platform (GCP) API 密钥
【发布时间】:2020-05-08 05:57:06
【问题描述】:

您的应用包含公开的 Google Cloud Platform (GCP) API 密钥。有关详细信息,请参阅此 Google 帮助中心文章。

易受攻击的位置

com.abc.Youtube_Player->onCreate

这就是我的代码在后端的样子

public class Youtube_Player extends AppCompatActivity implements YouTubePlayer.OnInitializedListener {

    // YouTube player view

    public static final String GOOGLE_API_KEY = "<api key>";

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_youtube__player);

    // Initializing video player with developer key
    mPlayerView.initialize(GOOGLE_API_KEY, this);
   }
}

【问题讨论】:

    标签: android android-layout google-cloud-platform youtube-api android-youtube-api


    【解决方案1】:

    您的代码中有 API 密钥。 作为最佳实践,您应该将密钥保存在安全系统中,例如 Google Secret Manager、HashiCorp Vault、加密的安全 GCS 存储桶等。如果这些选项对您不可行,仍然尝试将密钥放在其他属性文件中并控制对该文件的访问。

    【讨论】:

    • 感谢 pradeep。我已经实施了上述答案,希望 Play 商店能够重新收到警告。如果它不起作用。我会试试你的答案。如果您知道答案,目前这是我面临的问题。欢迎分享stackoverflow.com/questions/59855432/…
    【解决方案2】:

    您已经使用 'public static' 定义了您的 api 密钥,这意味着您的 api 密钥可以访问应用程序中的任何位置。并且有机会泄露您的 api 密钥。您需要从 ' 进行更改public static'private

    【讨论】:

    • 谢谢阿肖克。我会根据你的建议修改代码。如果可行,我会接受答案
    【解决方案3】:

    使用 API 密钥并避免在 Google Play 控制台中出现Leaked GCP API Keys security 问题的完整指南:https://stackoverflow.com/a/71155071/13387867

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-21
      • 2020-01-17
      • 2019-11-15
      • 2019-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-24
      相关资源
      最近更新 更多