简体   繁体   English

如何在Android上为Google Assistant实施OAuth 2.0授权?

[英]How to implement OAuth 2.0 Authorization for Google Assistant on Android?

I have created the gRPC binding for the embedded_assistant.proto and now need to authenticate with Google Assistant SDK before I could send and receive data. 我已经为Embedded_assistant.proto创建了gRPC绑定,现在需要先通过Google Assistant SDK进行身份验证,然后才能发送和接收数据。

I have followed this guide but I am confused as to how do I authenticate with the OAuth file (client_secret_client-id.json) I've created. 我已遵循本指南,但对于如何使用已创建的OAuth文件(client_secret_client-id.json)进行身份验证感到困惑。

Could somebody provide some example code to authenticate with the Google Assistant SDK? 有人可以提供一些示例代码来通过Google Assistant SDK进行身份验证吗?

Also, if possible could you also provide sample code on how to send a simple request from the user and get a response back from the Google Assistant after the Authentication process is setup? 另外,如果可以的话,您还可以提供示例代码,说明如何在设置身份验证过程后从用户发送简单请求并从Google Assistant获得响应?

You can look at how authentication is done in the example Android app for the Google Speech API, which should be much the same as needed for calling the Assistant API: https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech#set-up-to-authenticate-with-your-projects-credentials 您可以在示例Android应用中查看Google Speech API的身份验证方式,该方法应与调用Assistant API所需的身份大致相同: https : //github.com/GoogleCloudPlatform/android-docs-samples/tree / master / speech / Speech#set-up-to-to-authenticate-with-your-projects-credentials

Note: as described in the link, you would only want to use the client secret .json file for test Android apps, as this file should not be shipped in a released application. 注意:如链接中所述,您只想将客户端机密.json文件用于测试Android应用程序,因为此文件不应发布在已发布的应用程序中。 Some Google APIs support API key access from mobile devices, but this is method generally discouraged and not currently available for the Assistant API. 某些Google API支持从移动设备访问API密钥,但是通常不建议使用此方法,并且该方法目前不适用于Assistant API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM