如何从android应用中的服务器安全地获取凭据?

问题描述 投票:0回答:1

我正在尝试在我的Android应用中使用Google Cloud语音转文本API库。在Kotlin here上有一个来自Google的客户端代码示例。

它有一个代码片段:

        // NOTE: The line below uses an embedded credential (res / raw / sa.json).
        // You should not package a credential with real application.
        // Instead, you should get a credential securely from a server.
        context? .resources? .openRawResource (R.raw.credential).use {
            SpeechClient.create (
                SpeechSettings.newBuilder ()
                    .setCredentialsProvider {GoogleCredentials.fromStream (it)}
                    .build ())
        }

我的应用程序具有后端服务器。如何“从服务器安全地获得证书”?有没有例子?

android google-cloud-platform credentials
1个回答
0
投票

John提供的link应该为您提供一些见解,因为它研究了如何针对Web Server应用程序使用OAuth进行标识。

更符合您的实际情况,您可以查看OAuth 2.0 for Mobile & Desktop Apps,更确切地说,查看Android库的AppAuth。您可以按照官方文档中的建议遵循codelab

© www.soinside.com 2019 - 2024. All rights reserved.