Reputation: 51
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!
Upvotes: 5
Views: 7572
Reputation: 56
Had similar problem in Windows PS dotnet environment when trying to connect to DialogFlow Google Cloud Project recently and it appeared to be intermittent fault but it turned out to be global $env:GOOGLE_APPLICATION_CREDENTIALS
in windows PowerShell was pointing to a key file set when first setup access to GCloud days before and since regenereated keys in GCP Console
After generating new key file and setting it with new generated key file using $env:GOOGLE_APPLICATION_CREDENTIALS="[Path_To_JSON_Key_File]"
the problem went away but fix only lasted as long as the window was open, then after a while ran $env:GOOGLE_APPLICATION_CREDENTIALS
on a newly opened PS window and noticed it was still pointing to the old key file!
setting the system environment variable GOOGLE_APPLICATION_CREDENTIALS
to the value of [Path_To_JSON_New_Key_File]
fixed it, all newly opened PS windows had the correct key file and authenticated correctly using Service Account and .Net Google Cloud API calls worked after that
Upvotes: 0
Reputation: 5252
If you're getting the invalid_grant
error from Google : Instead of using the client ID
from google developer console as your value for client ID
in the code, try using the email address
value from developer console. This is actually what they expect. So, to confirm - the value for Client ID
should be the value from developer console ending @developer.gserviceaccount.com
Upvotes: 0
Reputation: 13954
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.
http://localhost/mirror-quickstart-php/oauth2callback.php
. If you're running it on example.com, it might be https://example.com/oauth2callback.php
. 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
.
Upvotes: 2