erebusnz / gapi-google-analytics-php-interface

GA:PI() - Google Analytics PHP Interface
167 stars 86 forks source link

"error": "invalid_grant", "error_description": "Bad Request" #145

Closed Cristianotx closed 8 years ago

Cristianotx commented 8 years ago

Hello , I have a problem , I downloaded and performed all the steps you went through in git , but I am getting the following error:

Fatal error: Uncaught exception ' Exception ' with message ' GAPI : Failed to authenticate user . Error : "{" error " : " invalid_grant " , " error_description " : " Bad Request " } " 'in E: \ clubecdv \ gapi \ gapi.class.php : 662 Stack trace : # 0 E: \ clubecdv \ gapi \ gapi.class.php ( 54) : gapiOAuth2- > fetchToken ( ' 647063759179 -co ... ', ' key.p12 ' , NULL) # 1 E: \ clubecdv \ gapi \ example.account.php (9): gapi -> __ construct ( ' 647063759179 -co ... ', ' key.p12 ') # 2 { main } thrown in E: \ clubecdv \ gapi \ gapi.class.php on line 662

please help me , I need a lot of it . thank you

gaelanlloyd commented 8 years ago

tl;dr -- Ensure the system time is properly set.

I just ran into the same issue, but what was strange was that my code worked on one computer but not another.

After some Google searches, I discovered an article that pointed to the machine's clock as a possible source for problems. If your computer's clock is too far out of sync with the actual time, Google won't authenticate the session and will return the error above.

I checked the time on the machine that didn't work, and it was indeed a different time from the machine that worked -- it was minutes off. So, I installed NTP on the machine, synchronized the time, and then my script worked.

Cristianotx commented 8 years ago

Good afternoon , I'm trying in every way to solve this error, but got no success. I wonder how install NTP server ? thank you

gaelanlloyd commented 8 years ago

Depends on your OS. Try doing a Google search for "{your-OS-name} install ntp".

Cristianotx commented 8 years ago

My server is windows server 2008 R2

Cristianotx commented 8 years ago

@gaelanlloyd Can you help me? looked in windows server 2008 r2 install google NTP , but I found several different sites , I do not know what the right . thank you

Cristianotx commented 8 years ago

@gaelanlloyd

I could put away an hour with the NTP , but STILL continues Giving Next Error: Fatal error: Uncaught exception ' Exception ' with GAPI ' message: Failed user authentication . Error: " {" error " : " invalid_grant " , " error_description " : " Bad Request " } " 'in E: \ clubecdv \ gapi2 \ gapi.class.php : 662 Stack trace : # 0 E: \ clubecdv \ gapi2 \ gapi.class.php ( 54) : gapiOAuth2- > fetchToken ( ' 754 340 140 777 -co ... ', ' key.p12 ' , NULL) # 1 E: \ clubecdv \ gapi2 \ example.account.php (9): gapi -> __ construct ( ' 754 340 140 777 -co ... ', ' key.p12 ') # 2 { main } thrown in E: \ clubecdv \ gapi2 \ gapi.class.php on line 662

gaelanlloyd commented 8 years ago

NTP is for Linux servers. I'm not sure what Windows servers use to synchronize their clock. Did you ensure that your system's clock is synchronized to actual time?

Cristianotx commented 8 years ago

My IS Server synchronized according to this site " http://ntp.br/ " but still featuring the same mistake . I would love to work it as accurate. If you like me to send emails and key.p12 for you to test in his , I would be very grateful .

Cristianotx commented 8 years ago

Good morning, I managed to solve lol was my mistake , was putting the key.p12 the wrong email. Thanks for listening! Would like to know one more thing , how can I get real-time users who are accessing my site? thank you again

sankalpsans commented 8 years ago

@Cristianotx great! Good to know the you were able to fix it. It would benefit if you close this issue now. :)