0

I am trying to learn the google Calendar API and unfortunately I've hit a snag.

I can't seem to get a the auth token to take.

I've done the quickstart.php and it works using CLI, but I want a web based app that will add to the users calendar once they have gone through auth to accept.

I've got to the point where I'm going to oauth, it's asking me to choose an account and to accept that "XXX" wants to manage the calendar, I accept, it returns back to the redirect URL with a GET['code'] - every piece of documentation then suggests you have to call;

$client->fetchAccessTokenWithAuthCode($_GET['code']);

Which I do, but then calling "$client->getAccessToken();" returns null

I have no idea where I'm going wrong, there's loads of documentation about the google API but loads of conflicting information too.

Any help would be greatly appreciated.

-Edit I've now managed to store the returned json but it says it's unauthorised...

{"error":"invalid_client","error_description":"Unauthorized"}

It's using the same clientID as the quickstart.php is, the same client_secret.json that matches the clientID

I'm still at a loss as to why it's returning incorrectly.

  • "It's using the same clientID as the quickstart.php "...you're supposed to create your own in the developer console. – ADyson Mar 23 '18 at 10:10
  • @ADyson it is my own, created in the developer console, I mean it's the same one I am using for the quickstart.php, ie using their example, my clientID in my quickstart.php – MagicalMidge Mar 23 '18 at 10:58
  • ok well we'll need to see a bit more code, one line of PHP on its own doesn't tell the story. We need one of these: https://stackoverflow.com/help/mcve – ADyson Mar 23 '18 at 16:10

0 Answers0