Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google_AuthException : invalid_grant

I'm trying to setup the config.php with my values but I get this fatal error:

Fatal error: Uncaught exception 'Google_AuthException' with message 'Error fetching OAuth2 access token, message: 'invalid_grant'.

I entered the client ID, secret, simple API key, location and sqlite database as the documentation says here: https://developers.google.com/glass/quickstart/php

Any idea of what I'm doing wrong?

Thanks in advance!

like image 662
user2328837 Avatar asked Nov 03 '22 23:11

user2328837


1 Answers

This happens when the URL where you're hosting your Glassware is not listed as a valid OAuth 2.0 redirect URI on the API console. Follow these steps to resolve it.

  1. First, determine your OAuth 2.0 redirect URI. This is where traffic goes at the end of the OAuth dance. The correct value depends on where you're running the php quick start. If you're running it on a local web server, it's likely to be http://localhost/mirror-quickstart-php/oauth2callback.php. If you're running it on example.com, it might be https://example.com/oauth2callback.php.
  2. Go to the API console. This link will lead you to the right panel (services), but double check that you're on the correct project.
  3. Scrolling down you should see a section of the page that looks like this: enter image description here. Click on 'Edit Settings...'.
  4. This triggers a pop-up where you can enter your OAuth redirect URIs. Add your redirect URI to the top text area. Make sure to put each URI on its own line.enter image description here
  5. Reload the page for the PHP Quick Start and everything should work.

If you're still having an issue, please share the full error message on the page and the value you have for the base url in config.php.

like image 182
mimming Avatar answered Dec 13 '22 11:12

mimming