Http input oauth2 google api

Hi,
I’m trying to store value from google api into influx via telegraf.
I do have a bash script that take care of the token and authentication for now, but since telegraf support oauth now, I would like to get rid of my script.

Here’s my config

[[inputs.http]]
  urls = [
    "https://smartdevicemanagement.googleapis.com/v1/enterprises/XXXXXXXXXX/devices"
  ]
  client_id = "XXXXXapps.googleusercontent.com"
  client_secret = "XXXXXXX"
  token_url = "https://www.googleapis.com/oauth2/v4/token"

  name_override = "XXXX_Nest"
  method = "GET"
  data_format = "json"
  interval = "60s"

I’ve tried a lot of different thing and there is no way I can have it working properly.
The error I have is :
2023-07-17 18:37:00 2023-07-17T22:37:00Z E! [inputs.http] Error in plugin: [url=https://smartdevicemanagement.googleapis.com/v1/enterprises/XXXXXXXX/devices]: Get "https://smartdevicemanagement.googleapis.com/v1/enterprises/XXXXXXXXX/devices": oauth2: "unsupported_grant_type" "Invalid grant_type: client_credentials"

Anybody have found a way to have google api working directly in telegraf?

R,
xk3tchuPx

It does not sound like the Google auth supports that grant type. This stackoverflow seems to confirm that as well. There may need to be custom support for whatever Google auth you are trying to use.

@xk3tchuPx did you setup a server-to-server aka “service account” for that API? I’m not exactly sure if there is a profile that does support the client credentials flow at all…