I followed all the steps mentioned in https://developers.google.com/sheets/api/quickstart/php
but I'm getting following error:-
PHP Fatal error: Uncaught Google\Service\Exception: { "error": "unauthorized_client", "error_description": "Unauthorized" } in /usr/local/var/www/web/vendor/google/apiclient/src/Http/REST.php:128
Other things aside, please make sure that you have chosen Web Browser and give the origin url is set correctly. For PHP, I suggest Web Browser option.
OR PERHAPS you have to generate the client Id and secret Id again and try.