Google Authentication Using PHP Library OAuth 2.0 - php

After many many hours searching I am still unable to figure out why I am receiving this error. It worked for a month and without touching any code, stopped working last night. The web app has been registered and Google+ api is turned on.
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/oauth2/v2/userinfo?key=MYKEY: (403) Access Not Configured. Please use Google Developers Console to activate the API for your project.'
I enabled Google+ Domain API just to see if it did anything. It allowed me to login 1 time and then continued to fail after that.

The developer key should be OK to pass every time as long as it matches the project that has been used for sign in (e.g. the client ID and the key come from the same developers.google.com/console project).
There was a problem yesterday with the userinfo endpoint that caused 403 for a number of users - that has now been resolved, but my guess is you were hitting that unfortunately!

So after further research and testing, I think I have the solution.
As mentioned by Jason OOO, $client->setDeveloperKey($key); was causing the problem.
As it turns out, Google PHP library needs $client->setDeveloperKey($key); passed the first time for validation, but causes an error if passed again after already being validated.
So, to fix this problem, check to see if user is already logged in and if they are do not pass $client->setDeveloperKey($key);

Related

Unable to establish session using blockchain-wallet-service

I installed blockchain-wallet-service correctly and work well.
When i try to login on my wallet, or do any action, i receive this error message:
error: Unable to establish session
All works well, i started the blockchain service correctly:
blockchain-wallet-service start
info: blockchain.info wallet service v0.22.0 running on http://127.0.0.1:3000
Waiting your answers.
I have the same error. It gets fixed by adding the ApiCode (at least at the first request for a walletId).
So the solution is request an ApiCode (here) and always include it at your requests. Ex:
http://$IP:$PORT/merchant/$guid/balance?password=$main_password&api_code=$api_code
- For me it also works an ApiCode requested for Payment v2 API
Yes, I have this error. I think it's of blockchain servers, I have many problem with it.
I've got this issue online, then i tried to change my Wallet ID and it's worked.

"The user is not enabled for live streaming" Error

I've been struggling quite a bit to solve the this issue. Basically, I'm just trying to connect to my youtube channel and get a list of future and past live broadcasts from my PHP based application. I was able to create a service account on the api console and it seems to be working fine now (as I've had some oauth authentication errors before) but now, I'm receiving this error in my error log:
Uncaught exception 'Google_Service_Exception' with message 'Error calling GET
https://www.googleapis.com/youtube/v3/liveBroadcasts?part=id%2Csnippet&mine=true:
(403) The user is not enabled for live streaming.' in etc...
My youtube account is associated with my personal #gmail.com account. I'm assuming that somehow I have to add the #developer.gserviceaccount.com to my youtube channel but even though I've tried to find any instructions for this, I was not able to find. I have live streaming enabled on my personal gmail account and also have some test events there.
Would appreciate and help in this matter please. Thanks!
Not sure if this will help, but in my case it turned out to be that the account somehow had 2 accounts:
a page with a strange page-id#pages.plusgoogle.com and
a normal Google email account user#gmail.com).
On top of that, I had issues with not renewing the access token: e.g sending an old access token.
Make sure you try the 2 sub accounts; one must have the videos under it. If you choose the wrong one, then you get that error above.

Google Glass Development Error: (403) Access Not Configured. Please use Google Developers Console to activate the API for your project

I am using the PHP version of the Google Glass Developer Kit. Setup everything per the sample code instructions. API/credentials are all fine, account billing is setup, have added the Mirror API to the project, but after I permission the application, I get the following Error:
An error ocurred: Error calling POST
https://www.googleapis.com/mirror/v1/timeline?key=xxxxxx
(403) Access Not Configured.
Please use Google Developers Console to activate the API for your project.
I have added the Mirror API and have Billing active and setup so have no idea why i am getting the error message. Testing the app via the Glass Explorer works just fine.
Google APIs have been known to misbehave when you provide both OAuth2 credentials and an API Key. Also since you have to use OAuth2 to access the Mirror API, the key=xxxxx isn't necessary anyway.
If you are using the Google APIs Client Library for PHP you can simply remove the following line from your code:
$client->setDeveloperKey($key);
Not entirely sure if this causes your issue, but I have come across similar issues in other Google APIs.
In Google API console for your project (https://code.google.com/apis/console/)
Make sure that your "Public API access" or "Key for server application" has allowed the IP address of your server.
Also make sure you have the proper "Redirect URIs", if you get refused, look at your php logs, I had this:
PHP Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/mirror/v1/timeline?maxResults=3&key=: (403) Access Not Configured. Please use Google Developers Console to activate the API for your project.'
use your $base_url + /oauth2callback.php to find out what the correct Redirect URI is.
I managed to solve the issue by adding the IP address and REDIRECT URIs and it runs both on my local machine and on the server. (same code, same key)
PS: I want to thank Scarygami, disabling the $client->setDeveloperKey($key); helped me find the solution.

Adwords API Bad Authentication

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.

Google Checkout error, "Build failed with an exception"

I want to implement Google Checkout in my PHP project (running on Apache). I put the callback URL in my merchant center account. My Checkout is in sandbox mode. When placing an order I get the following error message in my merchant center:
We encountered an error trying to access your server at myurl.org -- the error we got is
Send failed with code: 401.
Response body was: Failed to Get Basic Authentication Headers
Since neither version of this question has been addressed, I figure I'll add some advice to the one I edited:
I'm not at all familiar with Google Checkout and its API, but a quick Wikipedia search for HTTP error informs me that a 401 error is because authentication has failed. Note, this is not the same as the authentication being rejected (error 403: Forbidden) but rather that the actual attempt to authenticate failed. A good analogy might be to imagine going to a door, being asked for the secret password (which we'll say is Fedelio) and instead of saying "Applesauce" and getting beat up for trespassing (error 403) instead you respond with "Huh?" and the gate keeper simply stands there wondering if you even know what he meant by password.
The same wiki article refers to Basic Authentication in relationship to this error. I highly reccommend taking a look into that as well.
Long story short, your users need to authenticate when the URL is requested, but it sounds like you are trying to request the site server-side or through some kind of redirect, so the server is returning the 401 error instead of returning a login prompt.

Categories