I'm testing the OAuth2 service with google-api-php-client library to access UserInfo of logged users with their Google account. The code is taken from examples/userinfo/index.php with little change to cope with my host. When running the example, it passed through Google login form. When it came back to my site, an exception thrown as following.
Fatal error: Uncaught exception 'apiIOException' with message 'HTTP Error: (0) couldn't connect to host' in /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/io/apiCurlIO.php:120
Stack trace:
#0 /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/io/apiCurlIO.php(46): apiCurlIO->makeRequest(Object(apiHttpRequest))
#1 /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/io/apiREST.php(55): apiCurlIO->authenticatedRequest(Object(apiHttpRequest))
#2 /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/service/apiServiceResource.php(151): apiREST::execute(Object(apiServiceRequest))
#3 /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/contrib/apiPlusService.php(207): apiServiceResource->__call('get', Array)
#4 /home/ztbmwjhd/public_html/apis/at/googleplus/google-plus-access.php(40): PeopleServiceResource->get('me')
#5 /home/ztbmwjhd/public_html/apis/at/googleplus/index.php(2): include_once('/home/ztbmwjhd/...')
#6 {main}
throw in /home/ztbmwjhd/public_html/apis/at/googleplus/google-api-php-client/src/io/apiCurlIO.php on line 120
Thank you for your help
The error "HTTP Error: (0) couldn't connect to host" typically means theres a problem between your server and google. Are you connecting through a proxy?
Also, try to run "curl https://www.googleapis.com/discovery/v1/apis" from your command line.
Related
I tried the Example CLI PHP code from Google. The listFiles() method throws a 500 Internal Error from Google's servers, as shown in the stack trace:
bash-4.2$ php test.php
PHP Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/drive/v2/files?maxResults=10: (500) Internal Error' in /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php:79
Stack trace:
#0 /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php(44): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request))
#1 /home/ben/.../vendor/google/apiclient/src/Google/Client.php(556): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#2 /home/ben/.../vendor/google/apiclient/src/Google/Service/Resource.php(195): Google_Client->execute(Object(Google_Http_Request))
#3 /home/ben/.../vendor/google/apiclient/src/Google/Service/Drive.php(1783): Google_Service_Resource->call('list', Array, 'Google_Service_...')
#4 /home/ben/.../test.php(78): Google_Service_Drive_Files_Resource->listFiles(Arra in /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php on line 79
I deleted the saved credentials and tried again. That did not help:
bash-4.2$ php test.php
Open the following link in your browser:
https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=urn%3A
ietf%3Awg%3Aoauth%3A2.0%3Aoob&client_id=...&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&access_type=offline&approval_prompt=auto
Enter verification code: ...
Credentials saved to /home/ben/.credentials/drive-php-quickstart.json
PHP Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling GET https://www.googleapis.com/drive/v2/files?maxResults=10: (500) Internal Error' in /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php:79
Stack trace:
#0 /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php(44): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request))
#1 /home/ben/.../vendor/google/apiclient/src/Google/Client.php(556): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#2 /home/ben/.../vendor/google/apiclient/src/Google/Service/Resource.php(195): Google_Client->execute(Object(Google_Http_Request))
#3 /home/ben/.../vendor/google/apiclient/src/Google/Service/Drive.php(1783): Google_Service_Resource->call('list', Array, 'Google_Service_...')
#4 /home/ben/.../test.php(78): Google_Service_Drive_Files_Resource->listFiles(Arra in /home/ben/.../vendor/google/apiclient/src/Google/Http/REST.php on line 79
I searched through the github issues and stackoverflow questions tagged google-api-php-client, but did not find any clues. I logged into the developer console and clicked Logs, which resulted in the text
Failed to load.
Any ideas how to get more detailed information about 500 errors from Google?
try adding this to the beginning of the code in the file calling Google Drive API
date_default_timezone_set('America/New_York') //change timezone you want
Also make sure, folder permission inside the google drive is set.
i am using HybridAuth library for social logins.
everything is working perfectly on localhost.
and it was working on my hosting server too but now i am getting this errors suddenly:
when i tried with google:
Fatal error: Uncaught exception 'Exception' with message 'User profile
request failed! Google returned an error: exception 'Exception' with
message 'The Authorization Service has return: ' in
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php:82
Stack trace: #0
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/Provider_Model_OAuth2.php(114):
OAuth2Client->authenticate('4/P-5SuqvrU0DDy...') #1
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/Endpoint.php(175): Hybrid_Provider_Model_OAuth2->loginFinish() #2
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/Endpoint.php(56):
Hybrid_Endpoint::processAuthDone() #3
/home/moviesaints/public_html/dev/application/third_party/hybridauth/index.php(15):
Hybrid_Endpoint::process() #4
/home/moviesaints/public_html/dev/application/controllers/user/hauth.php(298):
require_once('/home/moviesain...') #5 [internal function]:
HAuth->endpoint() #6 /home/mov in
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/Auth.php
on line 147
and when tried with facebook:
Fatal error: Uncaught exception 'Exception' with message
'Authentication failed! Facebook returned an invalid user id.' in
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/Providers/Facebook.php:91
Stack trace: #0
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/Endpoint.php(175): Hybrid_Providers_Facebook->loginFinish() #1
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/Endpoint.php(56):
Hybrid_Endpoint::processAuthDone() #2
/home/moviesaints/public_html/dev/application/third_party/hybridauth/index.php(15):
Hybrid_Endpoint::process() #3
/home/moviesaints/public_html/dev/application/controllers/user/hauth.php(298):
require_once('/home/moviesain...') #4 [internal function]:
HAuth->endpoint() #5
/home/moviesaints/public_html/dev/system/core/CodeIgniter.php(359):
call_user_func_array(Array, Array) #6
/home/moviesaints/public_html/dev/index.php(202):
require_once('/home/moviesain...') #7 {main} Next exception
'Exception' with message 'Authentic in
/home/moviesaints/public_html/dev/application/third_party/hybridauth/Hybrid/Auth.php
on line 147
I have tried following solutions but still facing the same problem:
hybridauth-php-facebook-returned-an-invalid-user-id
hybridauth-facebook-returned-an-invalid-user-id
laravel4-hybridauth-facebook-authentication-failed-facebook-returned-an-invalid
Github Solution
Google group Solution
Help please, It will be appreciated.
I'm not sure this is true or not but after I was able to get my installation working I still could not get Facebook to work, no matter how hard I tried. My guess is that the SDK files used by Hybridauth for Facebook are deprecated. Facebook released new versions and quite a reworked SDK recently. That could be why there seem to be a lot of people suffering from issues with the Facebook provider right now.
i have to use google api in my project using php
the project : using google search engine and gathering urls and their source pages
i downloaded google api php client and i followed what ever is written here
https://code.google.com/p/google-api-php-client/
after running i ge this error:
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling GET https://www.googleapis.com/plus/v1/people/me/activities/public?key=[REDACTED]: (403) Access Not Configured' in C:\xampp\htdocs\google-api-php-client\src\io\Google_REST.php:66 Stack trace: #0 C:\xampp\htdocs\google-api-php-client\src\io\Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest)) #1 C:\xampp\htdocs\google-api-php-client\src\service\Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest)) #2 C:\xampp\htdocs\google-api-php-client\src\contrib\Google_PlusService.php(58): Google_ServiceResource->__call('list', Array) #3 C:\xampp\htdocs\googleapitest.php(31): Google_ActivitiesServiceResource->listActivities('me', 'public') #4 {main} thrown in C:\xampp\htdocs\google-api-php-client\src\io\Google_REST.php on line 66
i am completely confused and don't know what to do
That error often means you're not matching your access requirements in the API console - i.e. if you have IP or referrer restrictions configured.
Just remove your developer key and add the scope
'www.googleapis.com/auth/userinfo.email',
'www.googleapis.com/auth/userinfo.profile',
'www.googleapis.com/auth/plus.login',
'www.googleapis.com/auth/plus.me'));
I'm trying to use the php dropbox sdk, but i got these error
Uncaught exception 'OAuthException' with message 'making the request failed (Peer certificate cannot be authenticated with known CA certificates)' in C:\xampp\htdocs\mydropbox\Dropbox\OAuth\PHP.php:126 Stack trace: #0 C:\xampp\htdocs\mydropbox\Dropbox\OAuth\PHP.php(126): OAuth->getRequestToken('https://api.dro...') #1 C:\xampp\htdocs\mydropbox\index.php(18): Dropbox_OAuth_PHP->getRequestToken() #2 {main} Next exception 'Dropbox_Exception_RequestToken' with message 'We were unable to fetch request tokens. This likely means that your consumer key and/or secret are incorrect.' in C:\xampp\htdocs\mydropbox\Dropbox\OAuth\PHP.php:132 Stack trace: #0 C:\xampp\htdocs\mydropbox\index.php(18): Dropbox_OAuth_PHP->getRequestToken() #1 {main} thrown in C:\xampp\htdocs\mydropbox\Dropbox\OAuth\PHP.php on line 132
I did tried so many times, to use OpenSSL to generate new and follow all the instruction ,but it still giving me this errors.
Refer Source:http://help.discretelogix.com/miscellaneous/installing-self-signed-ssl-certificate-on-wamp-server.htm
I found a github that do not use the CA certification, or maybe it's already taken care for me.
https://github.com/BenTheDesigner/Dropbox
it's working well for me.
I am newer to the Google Plus Api, but I have followed each and every rule to integrate G-Plus API in my WEB. But every time I get stuck at the issue:
Fatal error: Uncaught exception 'apiAuthException' with message 'Error refreshing the OAuth2 token, message: ''' in C:\AppServ\www\googleplus-source\google-api-php-client\src\auth\apiOAuth2.php:203
Stack trace:
#0 C:\AppServ\www\googleplus-source\google-api-php-client\src\io\apiCurlIO.php(51): apiOAuth2->sign(Object(apiHttpRequest))
#1 C:\AppServ\www\googleplus-source\google-api-php-client\src\io\apiREST.php(55): apiCurlIO->authenticatedRequest(Object(apiHttpRequest))
#2 C:\AppServ\www\googleplus-source\google-api-php-client\src\service\apiServiceResource.php(148): apiREST::execute(Object(apiServiceRequest))
#3 C:\AppServ\www\googleplus-source\google-api-php-client\src\contrib\apiPlusService.php(204): apiServiceResource->__call('get', Array)
#4 C:\AppServ\www\googleplus-source\google-plus-access.php(40): PeopleServiceResource->get('me')
#5 C:\AppServ\www\googleplus-source\index.php(2): include_once('C:\AppServ\www\...')
#6 {main} thrown in C:\AppServ\www\googleplus-source\google-api-php-client\src\auth\apiOAuth2.php on line 203
What could be the reason for this error?
What could be the reason for this error?
The reason for this error (a Fatal error) is given in the error message: Uncaught exception. That means an exceptionÂDocs has been thrown and was not caught. This results in a fatal error.
Most likely in your case, the root cause of the problem highlighted in the exception message is misconfiguration and/or wrong API usage. As you have not posted any code in your question, you should read the API documentation first and double check your usage of the API and it's configuration.