简体   繁体   中英

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.

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.

Could somebody provide some example code to authenticate with the 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?

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

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. Some Google APIs support API key access from mobile devices, but this is method generally discouraged and not currently available for the Assistant API.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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