1

I'm trying to create a Chatbot in Gooogle Business Communications (https://business-communications.cloud.google.com/), I have created the agent, the Webhook is properly configured and I downloaded the "Service account" json file.

I'm able to receive messages in my webhook, now I want to reply back to the user, and here is the problem. I'm following this instructions for Service Accounts (JWT manually created and executing through postman) and also I'm trying with the Google API PHP Client

In both cases, I have a response from https://oauth2.googleapis.com/token but the problem is that I'm getting only an id_token, but I need an access_token.

This is the response when this endpoint https://businesscommunications.googleapis.com/v1/partners/{Partner_ID} is executed using id_token:

{
"error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
}

}

I have installed the oauth2l command line tool and by executing next command I'm able to obtain a valid access_token:

oauth2l fetch --type oauth --credentials ./service_account_key.json --scope businesscommunications

With this token I can execute the previous endpoint (or the reply message endpoint).

Maybe there is a parameter that I'm missing when I try to get the access_token.

Thanks!

1 Answers1

0

Google 'google oauth playground' and use your credentials to generate the access token.

Useful resources:

How can I verify a Google authentication API access token?

oauthplayground invalid grant, trying to get refresh token google oauth

Youzef
  • 616
  • 1
  • 6
  • 23