androidthings / sample-googleassistant

Google Assistant API sample for Android Things
Apache License 2.0
466 stars 147 forks source link

I don't know how to use this google-oauthlib-tool tool to get credentials.json #89

Open 2014james opened 5 years ago

2014james commented 5 years ago

I installed the python environment and installed the google-oauthlib-tool package via the pip command. I don't know the python language. I don't know how to use this google-oauthlib-tool tool to get credentials.json. Can anyone tell me the specifics? How to use, my project is android, thank you very much

Fleker commented 5 years ago

The instructions are listed in the README. You need to generate the credentials.json based on the client_secret_xxx.json file you download from the Actions console.

google-oauthlib-tool --client-secrets client_secret_XXXX.json \
                     --credentials app/src/main/res/raw/credentials.json \
                     --scope https://www.googleapis.com/auth/assistant-sdk-prototype \
                     --save
2014james commented 5 years ago

Hello, the credentials have been solved, I want to achieve the function is: develop an app like Google assistant assistant assistant to run on the smartphone, can this demo run directly on the smartphone, I do not know what this Google assistant has to do with Android things, I see the code about hardware LED lights, I do not understand what it means, Ma. Thank you for your help.

2014james commented 5 years ago

Hello, why does the JSON I got have no credential field?

Fleker commented 5 years ago

You should read about Android Things and the platform differences between it and a standard mobile app.

After generating credentials.json, you will get a file that contains a refresh token, among other fields, which will enable the application to authenticate to your account.

2014james commented 5 years ago

@Fleker Hello, can you explain the specific problem? I don't know much about things, and it took me a long time to study the credentials. At present, it's rather urgent. I want to make demo run quickly to determine if it's the effect I want. Thank you.

Fleker commented 5 years ago

The Google Assistant API does not work anonymously. It needs to be authenticated with a user's account, which will provide personal answers to that user.

You first need to download a client secret from the Actions console. The client secret JSON essentially contains a project username and password, which allows the google-oauthlib-tool to authenticate to the project-level.

After that, you need to give the project permission to use your user account. Once that happens, it will generate a credentials.json, which will allow the app to authenticate as you and programtically call the Google Assistant.

AcidRobot commented 4 years ago

I have been trying to get this to work for hours. I have the client_secrets_xxx.json but when I navigate to the "authorize this application url" I get I'm trying to register a hardware device and don't want to configure an oAuth2 server, that seems RIDICULOUS!



Error: restricted_client

A native application: Coffee Maker

You can email the developer of this application at: unconfiguredapp@google.com

This app is not yet configured to make OAuth requests. To do that, set up the app’s OAuth consent screen in the Google Cloud Console.

Learn more

Request Details
response_type=code
client_id=xxxx
redirect_uri=urn:ietf:wg:oauth:2.0:oob
scope=https://www.googleapis.com/auth/assistant-sdk-prototype
state=lgMkmlmtvGQZhkWS1jeMg77HEyANEJ
prompt=consent
access_type=offline
That’s all we know.```