last day (14 days later) » 

6:53 AM
0
A: Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }

DaImToI think you have a problem with the order of how you are doing things. You are creating the service before you are getting authentication. This is an example using google analytics api. <?php session_start(); require_once 'Google/Client.php'; require_once 'Google/Service/Analytics.php'; /****...

 
@DalmTo - if Im creating the service before I getting authentication, then why it's properly working on the localhost environment.
 
Google_Auth_AssertionCredentials needs to be created first because it is sent to $client then the Service is created using the $client that has its authentication. You are doing it backwards
 
if I'm doing it backwards why it's working under localhost environment.it's not seems to that matter buddy..but nice try...thanks.
 
Option nr 2: check the server clock make sure it is set correctly. It needs to be in sync with NTP. If its not it thinks there's something wrong with your authentication and you will get a invalid_grant.
 
Yep that's a kind of acceptable answer but what's NTP ? and how do I sync with my Hosting server time.
 
6:53 AM
NTP is network time protocol for clock synchronization between computer systems. en.wikipedia.org/wiki/Network_Time_Protocol What type of server is it? Just check its time is it the correct? If not set the time.
morning
 
Hi this my server PHP info
 
is it running a Linux?
 
How can I change the server time Sync with Google OAuth2.0 server
Yes it's Linux
 
sec my Linux is rusty I need to google that one.
 
Oki take your time
 
6:57 AM
hwclock --show
whats that say?
is it ubunto or ?
 
Mon Aug 18 23:05:27 EDT 2014
Server time
Time Zone : America/New_York
 
where are you now?
hmm doesn't matter that time isn't right its like 3am east cost USA time.
 
In Sri Lanka Time is now 12.38 PM - Date - 19/08/2014
 
hwclock --set --date="2014-08-19 12:38:05" --localtime
try that.
that's setting the hardware clock there is also a system clock.
but you really need to get ntpd up and running on the server that will ensure that it always stays set correctly. cyberciti.biz/tips/…
find instructions on the distribution of Linux you are running on how to install ntpd or you are going to have this problem again.
 
7:17 AM
Thanks for great info... but still I have fuzzy mind. Is that mean my app can't access people who living US ? ( if I change Server time to local time )?
 
Ok, here is the long story.
 
then they will get same Error as I currently getting
 
when Google gives you some authentication information.
{"access_token":"ya29.ZQCVQYPvb2DjiCEAAAC_43ZWMGAU9urVt-6jpc7xdPParCG5BJzhIaxfmv‌​DB553SssY56_DUw3MBQHWxtfI","token_type":"Bearer","expires_in":3600,"refresh_token‌​":"1/HceVdYYdVjUnY5zoeAdzHI6i-qwJexQtTJv-AI2F39c","Issued":"2014-08-18T14:00:13.4‌​78+02:00"}
in there you will notice a issued time. when you go to use it the issued time wont match the time on your server and google knows that.
So your time has to be set to the correct time that the rest of the world.
in your case your off by like 3 hours. so your authentication is expired before you have a chance to use it.
 
No no it Im off by 13 hours approximatly
 
As long as we get your server set to the correct time that it is for you now Google can figure it out.
that's even worse :)
its like 3 am west cost usa for me I forgot your not where I am. Time zone is such a pain to play with isn't it
you need to get ntpd running on the server. I am surprised its not its normal a default thing on servers these days.
 
7:25 AM
Yes of course ...If Im asked my Hosting managers to adjust Server time what would I say to them...? it's ok to send this ( hwclock --set --date="2014-08-19 12:38:05" --localtime ) directive to them ?
 
no make your self look smart and ask them why ntpd isn't running and ask them to fix the time on the server.
trust me they know how to set the server time my bet is that ntpd crashed and they haven't restarted it. they don't know its off
if they don't know how to set the time then you seriously need a new hosting manager
ntpd is a demon or automatic program on a Linux server that goes out and checks every now and then that it has the correct time. If it doesn't it sets itself to the correct time.
 
is there a simple way to check whether server NTPD service is up and running ?. at the moment I'm now log into my hosting account with root permission. before I ask it from hosting managers how do I check it?
I just Google'ed I found : $ ntpstat
*command
 
go for it :)
it wont hurt anything
nice they give you root
 
Big big big thanks for your time and help...really appreciate...people like you...
 
people like you inspire me. I just made a post im going to start collecting error messages and there fixes. I am tired of Googleing them all the time I have seen this error before daimto.com/google-api-error-list
all the tutorials on my site are inspired by questions asked on stack.
 
7:41 AM
Thanks ...it's really cool articles ...thanks again...I'm about to leave now for having my lunch. see you next time...Thanks
 
post back if it works or not
 
Sure I'll definitely POST it ..........thanks and Bye... :)
 
 
5 hours later…
12:49 PM
Thank you very much my problem with Google Prediction API has finished now. my Hosting provider using Virtuozzo VPS that they informed me that they are not using NTP to sync with Timeserver. But they managed to VPS node sync with timeserver.now my App is working properly with my hosting. Big thanks for you.
 

last day (14 days later) »