1

right now i'm using google-calendar-api with Laravel, i want to create a reminder, and let the user decides if he wants to shows it in his Google Calendar (based in his gmail account).
Right now this code works fine: enter image description here

I got an error when trying to add an attendee, Googling i found out that you need to "impersonate" the user you want to invite, so i tried the next approach:

enter image description here

And getting this error:

enter image description here

What do you guys think am i doing wrong? In my Google Api Console i'm using a Service Account, i tried with several keys, i enabled Domain Wide Delegation: enter image description here

Nothing works, as i said, i can create and list the events, but can't invite anyone.

Thanks in advance!

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Kashorako
  • 53
  • 1
  • 9
  • Please edit your question and include your code not pictures of your code. – Linda Lawton - DaImTo Aug 27 '20 at 14:40
  • Did you grant domain-wide delegation to the service account? Checking `Habilitar delegacion en todo el dominio de G Suite` is only the first step, check and follow [this](https://developers.google.com/identity/protocols/oauth2/service-account#delegatingauthority). Also, the user who created the event is by default an attendee, you don't need to add it. Why are you doing that? – Iamblichus Aug 28 '20 at 08:06

1 Answers1

0

The error message

the client is not authorized to request a token using this method

Means that the client credetials that you created on Google developer console do not match the login method you are using

You apear to be using code designed for use with a service account

    // Create and configure a new client object.        
    $client = new Google_Client();
    $client->useApplicationDefaultCredentials();
    $client->addScope([YOUR SCOPES HERE]);
    return $client;

To use this you need to create service account credentials on Google developer console. You have not.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • This isn't very helpful. I've been through every 'How To' and it still doesn't work with a non-gsuite account. – tlorens Sep 16 '20 at 14:28
  • Go to Google developer console download new service account credentials. Take the service account email and share what ever calendar you want with it. you don't need to use gsuite with a service account and Google calendar what you need is to use the correct credential type which you are not. – Linda Lawton - DaImTo Sep 16 '20 at 15:27
  • it would be helpful if you would post your code and not picture so that I can test it but I asked you to do that a already – Linda Lawton - DaImTo Sep 16 '20 at 15:28
  • The only answer that works is here: https://stackoverflow.com/questions/62421695/google-calendar-api-php – tlorens Sep 16 '20 at 15:30
  • Well in that case im glad i could help you there. – Linda Lawton - DaImTo Sep 16 '20 at 17:05