I used my google account developer for quite a long time (2-3 months).
I created a Google Oauth2 app, got clientid, access token and all the stuff. Working perfecty. My website's using a PHP client for OAuth2 auth.
Today I'm went to the website and I received the error:
Error fetching OAuth2 access token, message: 'invalid_request: Missing
parameter: client_id'
I went to my developer console (thinking the client_id was different for some weird reason) and I found out I can't access the console anymore, Google is asking me a fee of 25 USD to access again.
Is it normal? Why such a misleading error message from the PHP client?
Related
I am using google drive api with laravel for a continuous backup, so I am using following packages
"nao-pon/flysystem-google-drive": "~1.1", and
"spatie/laravel-backup": "^6.14"
I have set up google drive api v3 with refresh token and put it into .env
FILESYSTEM_CLOUD=google
GOOGLE_DRIVE_CLIENT_ID=****.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=****
GOOGLE_DRIVE_REFRESH_TOKEN=****
GOOGLE_DRIVE_FOLDER_ID=****
so everything works properly, and I can use google drive as a disk to store the back up everyday through a cron job, the only problem is after a week the refresh token gets expired(I assume) and stops working with this error message,
Failed to authenticate on SMTP server with username "****" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535 Incorrect authentication data
if I change the refresh token again from oathplayground and place it into .env it starts working again for a week.
so how can I solve this problem thus I need not to generate the token every week.
Oauth playground is only intended to be used for testing. Tokens created on the playground will only work for about two weeks.
You should implement your own authorization.
It says in the OAuthPlayground that it will revoke authorization tokens after 24 hours.
.
The process of setting up a GCP project, consent screen and authorization is the same for all programming languages. Have a look at this answer for step by step guide to authorization.
I have a project where the Google Sites API stopped working in March 2019. I am continuously getting the following error message.
I have checked necessary things like API is enabled, scopes and Google Admin API access enabled.
[26-Apr-2019 13:42:02 Europe/Minsk] PHP Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{
"error": "unauthorized_client",
"error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."
}
google-api-php-client\src\Google\Auth\OAuth2.php(314): Google_Auth_OAuth2->refreshTokenRequest(Array)
google-api-php-client\src\Google\Auth\OAuth2.php(239): Google_Auth_OAuth2->refreshTokenWithAssertion()
google-api-php-client\src\Google\Service\Resource.php(214): Google_Auth_OAuth2->sign(Object(Google_Http_Request))
google-api-php-client\src\Google\Service\Directory.php(1703): Google_Service_Resource->call('list', Array, 'Google_S in google-api-php-client\src\Google\Auth\OAuth2.php on line 363
I have not made any changes to my code and to the CREDENTIALS in the Google Developer Console or to the G Suite. What could have gone wrong for the API to stop working suddenly?
Thank you very much in advance.
Got the same surprising behavior with a NodeJS script using Google Sites API.
In GSuite developer admin console, some scopes for Google Sites have been removed (!) a few months ago, and must be replaced by a new one:
Authenticate to https://console.developers.google.com
In the top bar, choose the project corresponding to your app
In the search field at the top, type "Marketplace SDK"
Choose option G Suite Marketplace SDK
Go to Configuration
In section OAuth 2.0 scopes remove scopes:
https://sites.google.com/feeds/site
https://sites.google.com/feeds/activity
https://sites.google.com/feeds/content
Add scope:
https://sites.google.com/feeds
click Save changes
This hint helped me. Using the OAuth 2 API playground shown a much more precise error when using an "old" scope (Invalid legacy scope provided)
I'm currently using the GAPI tool to extract date from my Google Analytics account using an OAuth 2.0 account created in the Google Developers Console. It works flawlessly except for one thing - every so often, the script will fail with the following message:
'GAPI: Failed to request report data. Error: "{"error":{"errors":[{"domain":"global","reason":"authError","message":"Invalid Credentials","locationType":"header","location":"Authorization"}],"code":401,"message":"Invalid Credentials"}}"
My assumption is that the Oauth 2.0 token is expiring, preventing further data access. I have been manually restarting the process so far, but it would be far more efficient to automatically refresh the token prior to expiration. If anyone knows the best way to accomplish this, I'd appreciate hearing it. Thanks.
I've been crawling the internet all morning trying to figure this out. I'm trying to get access to a Adwords test account through the API but I keep receiving "An error has occurred: { "error" : "invalid_grant" }". I've seen this is quite a common problem so perhaps if I outline what I've done step by step someone can correct me. Hopefully!
Created a Google adwords account and set up a campaign.
Created a MCC account. Added Google adwords account and applied for API access (pending). Noted API key, client id for auth.ini.
Created a test MCC account and added Google adwords account. Noted client id for auth.ini.
Using the Google account of both MCC accounts went into the API console and created a new installed application app. Noted all keys/tokens.
Downloaded the PHP code examples and libs. Ran get GetRefreshToken.php, granted accesses to app(s) and noted refresh token for auth.ini
Set up auth.ini populating developerToken, userAgent, clientCustomerId, client_id, client_secret and refresh_token.
Now I've tried using BOTH sets of tokens and ids from the test MCC account API console and the live MCC account API console. Both give me the same error. I've tried regenerating all tokens several times.
Gave up and came crawling to StackOverFlow.
Is the invalid_grant message related to Auth or my developerToken token not being activated yet (sure it said I could use my test account though) or because I haven't set up any of the billing?
In my case the problem was at step 5 in your list; I had copied the authorization code from my browser after granting access, rather than the refresh token generated by GetRefreshToken.php after I pasted the authorization code there.
I had the same situation for a long time.
But solution was very simple.
The code getting after authorizing the Google is not your refresh token.Its is only an access token(I guess.)
You have to add this code to GetAccessToken's $code variable function in getrefreshtoken.php file and it will return the actual Refresh token.
This solved my issue.
It is very important to note that the SDK is designed to be used through PHP-Cli. So please don't use it via browser. If you still run it by commenting out return line you'll get into further problems to comment that on each file :)
I am using Adwords API from last 3 months and all of a sudden today it is coming up with error message as follows:
Uncaught exception 'AuthTokenException' with message 'Failed to get authToken. Reason: BadAuthentication'
I am using google adwords V201101 php library with auth.ini containing all user details and settings.ini with https://adwords.google.com not sandbox environment. Can anyone help me with this please???
Thanks,
Murali.
you may requesting authToken from ClientLogin service too many times, that is way you get 'CaptchaRequired'.
Request authToken just for the first time, and then cache it for subsequent requests.
Check this out http://goo.gl/TOX6N
I recently had this problem trying to connect to Google DFP. I copied perfectly working code from my localhost after development and ran it on my remote cloud server. I then received the
Failed to get authToken
message. The reason was that google was blocking the attempted login as a security measure because it was a new location. I had to log into the google account (from the web) with those credentials in order to see the message and confirm the added login location. Everything worked fine after that authorization.
I've stumbled across this question and thought that this info may help someone else.
BadAuthentication means your username/password is incorrect. May be someone changed the account password, may be auth.ini got modified by mistake.
See detailed error codes here: http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html#Errors
Cheers,
Anash
I started getting this error after somebody in my organization updated the password for the account my app was using to log in. The best way to avoid this happening again is to use OAuth2.
It's as easy as going to the Google API console and creating a Client ID for Installed Applications (under API access) for your project. You then use the Client ID and Client Secret in your Adwords API auth.ini file.
Next you run the examples/AdWords/Auth/GetRefreshToken.php script which will have you grant your app access to your Adwords account. You'll end up with a Refresh Token which you need to add to your auth.ini.
The ClientLogin (username and password) method of authentication is being deprecated in favour of the above so best to migrate ASAP.