Search code examples
javakotlinoauth-2.0postmangoogle-oauth

Using google API using OAuth2 in Postman or Java/Kotlin


I am here to ask you a for a help with OAuth2 for Google API.

Short story: I am trying to access Google Home through API to use Air Condition.

I saw many tutorials on this, but since google is changing it's api very often I don't know how to continue.

I already have a client ID which I made through Google Console. Now I need to create OAuth2 token to communicate with the API either through Postman or directly from Android Kotlin app.

Google console gave me following parameters:

client_id, project_id, auth_uri, token_uri, auth_provider_x509_cert_url

According to this site: GoogleSite I can see that there should be other types of parameters (Or I am wrong maybe?)

Can someone help me with getting OAuth2 Token either from Postman or Java/Kotlin ?

Thanks a lot


Solution

  • From what I understand Cloud to Cloud API is for device manufacturers. Google focusing on getting every provider compatible with Google Home, so users can use it. I smell XY problem here. There's extensive docs on OAuth, but I think you rather need a way to talk to Google Home's Assistant backend, just like Google Home / Nest / your phone does.

    I think you need this approach: talk to Assistant with text prompts to control your things.

    https://stackoverflow.com/a/54135312/253468

    For that I would follow this tutorial:

    https://developers.google.com/assistant/sdk/guides/service/python

    here's some code that looks promising:

    https://github.com/googlesamples/assistant-sdk-nodejs

    You can choose another language you're more comfortable with:

    https://github.com/orgs/googlesamples/repositories?q=assistant-sdk