This is a continuation of my previous post: Google Contacts data API giving 500 Error.
You can get the my code and how I am ca开发者_JAVA百科lling CURL in the above post. Previously, I was getting a 500 Error intermittently, but once I rest my client_secret using Google API console, it was fixed for the time being.
But now, I am getting {error:invalid_grant} all of a sudden when I am requesting for the access token. What might be the reason behind this error?
I searched a few forums where they have said that this error can arise because of sending the POST parameters in the URL itself instead of using them in the POST body. But, to me, it seems that I haven't done anything of that sort in my code.
Also there is no error description along with the error type.
Another thing, I am actually urlencoding all the parameters (e.g client_secret,redirect_uri and even grant_type) , can this be the reason?
I had echoed out the $post variable containing the POST parameters in the log file, and it shows something like the following:
code=4%2Fsb898gAIIsd20FQk69yPvASTwN1s
&client_id=33137499441.apps.googleusercontent.com
&client_secret=<client_secret>
&redirect_uri=http%3A%2F%2Fwww.plus-one-me.com%2Foauth2callback&grant_type=authorization_code
Feel free to suggest any better and convenient way to implement the importing of Gmail contacts.
精彩评论