【问题标题】:GoogleCredentials reference not resolved with existing dependenciesGoogleCredentials 引用未通过现有依赖项解析
【发布时间】:2022-11-14 12:01:26
【问题描述】:

在我不断尝试安全地创建和使用 Oauth 2 令牌的过程中,我现在尝试通过以下代码获取令牌:

    private static String getAccessToken() throws IOException {
    GoogleCredentials googleCredentials = GoogleCredentials
            .fromStream(new FileInputStream("service-account.json"))
            .createScoped(Arrays.asList(SCOPES));
    googleCredentials.refreshAccessToken();
    return googleCredentials.getAccessToken().getTokenValue();
}

但是,GoogleCredentials 没有解决。我需要向我的应用程序 gradle 文件添加什么依赖项来解决这个问题?

【问题讨论】:

    标签: android firebase-cloud-messaging access-token android-security


    【解决方案1】:
    implementation com.google.auth:google-auth-library-oauth2-http:1.2.2
    implementation platform(com.google.firebase:firebase-bom:31.0.2)
    
    implementation com.google.firebase:firebase-analytics
    implementation com.google.firebase:firebase-messaging:23.1.0
    

    【讨论】:

      猜你喜欢
      • 2018-02-27
      • 1970-01-01
      • 2016-12-28
      • 2017-05-06
      • 2016-12-25
      • 1970-01-01
      • 2015-05-27
      • 2019-08-19
      相关资源
      最近更新 更多