简体   繁体   English

在Android上验证Google Cloud API

[英]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.

相关问题 使用 Google API 库进行身份验证,用于 Java 到 Google 云 - Authenticating with Google API library for Java to Google cloud 使用Google Calendar API进行身份验证 - Authenticating with Google Calendar API 使用AccountManager使用Google API进行身份验证 - Authenticating with Google API using AccountManager 适用于Google Cloud Datastore的android中的Google protobuf api - google protobuf api in android for google cloud datastore 在Cloud Endpoints和API Explorer上对用户进行身份验证(同时使用Firebase和Google身份验证) - Authenticating users (using both Firebase and Google authentication) on Cloud Endpoints and API Explorer Google Play游戏未在Android中进行身份验证 - Google Play Games not authenticating in Android 使用Java API的服务帐户验证Google API - Authenticating Google API with a service account with Java API 如何设置Google Cloud Platform并开始在Android应用中使用API​​? - How to setup Google Cloud Platform and start using API in Android app? 如何在 Android Studio 中使用 Google Cloud API Speech To Text - How to use Google Cloud API Speech To Text In Android Studio 如何在Android Studio中使用Google Cloud Translation API? - How to use Google Cloud Translation API in Android Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM