Search code examples
phpgoogle-apiservice-accountsgoogle-search-console

Use Service Account to connect search console via Google-php-API


Have been struggling to connect to Google API via PHP using Service Account. If to use examples provided by API (link) and google developers site itself (or any other source from google searches), I'm getting the error

{ "error": "invalid_grant", "error_description": "Invalid JWT Signature." }

And if to search how to connect using JWT as well, there are only JS or JAVA or PYTHON examples.

Any real experience out there how to correctly get the connection? I have:

  1. service account set up and allowed to use Search Console (and analytics)
  2. set up the API to server
  3. added service account address to Search Console for site we need the data from
  4. downloaded and added the key file.

All goes well till I start making the actual request for data. Then the JWT error appears.

ANY input is appreciated!


Solution

  • Got solution by removing service account from google console and created new.