[英]Authenticating google cloud api on android
I'm using the Google Cloud Speech-to-text API, within my android app. 我在我的Android应用程序中使用Google Cloud Speech-to-text API。
How would one authenticate to the API without the ability to set the necessary environment variable? 如果没有设置必要的环境变量的能力,如何对API进行身份验证?
I've not been able to find any documentation covering authenticating on android, with the environment variable, and file 我无法找到任何关于android,环境变量和文件验证的文档
Your question is unclear but I think you're trying to use a service account ("file") and perhaps GOOGLE_APPLICATION_CREDENTIALS
("environment variable") to authenticate your app. 您的问题尚不清楚,但我认为您正在尝试使用服务帐户(“文件”)以及GOOGLE_APPLICATION_CREDENTIALS
(“环境变量”)来对您的应用进行身份验证。
You should not. 你不应该。
Service Accounts are best applied to software (eg another service) that's running autonomously (ie not directly by a human user) that needs to authenticate with a Google API. 服务帐户最适用于需要使用Google API进行身份验证的自主运行的软件(例如,不是由人类用户直接运行)。
For an Android App, I think you probably wish to authenticate the human user of your app against the Google API using the full OAuth flow were your user is prompted to approve use of the Google API and then, your application is authenticated as this user. 对于Android应用程序,我认为您可能希望使用完整的OAuth流程针对Google API对应用程序的人类用户进行身份验证,前提是系统提示您的用户批准使用Google API,然后对您的应用程序进行身份验证。
See here for an explanation of the 3 primary authentication methods: https://cloud.google.com/docs/authentication/ 请参阅此处以了解3种主要身份验证方法的说明: https : //cloud.google.com/docs/authentication/
See here for an overview of authenticating a human user to a Google API: https://cloud.google.com/docs/authentication/end-user 有关向Google API验证人类用户身份的概述,请参阅此处: https : //cloud.google.com/docs/authentication/end-user
See here -- less confident in this as I've not used it -- as a way to authenticate Android apps using Google Sign-In (ie OAuth): https://developers.google.com/identity/sign-in/android/sign-in 请参阅此处-对此不太有信心,因为我没有使用过它-一种使用Google登录(即OAuth)对Android应用进行身份验证的方法: https : //developers.google.com/identity/sign-in/安卓/登入
HTH HTH
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.