Bhavik Narang
Bhavik Narang

Reputation: 119

Using a service account to create google calendar event, can't change creator name

I have managed to use the Node.Js library, googleapis (more information here) to create the google calendar event. I am using a service account and passing the relevant details into the auth function to get a JWT token:

const auth = new google.auth.JWT(
    CREDENTIALS.client_email,
    null,
    CREDENTIALS.private_key,
    SCOPES,
    "[email protected]"
);

Note: the "[email protected]" account is in fact a google account, but I'm using an alias on this post for security purposes.

I am then using the auth variable to insert the event into the calendar. The resource I pass into the insert function is using the properties as mentioned on the docs:

let event = {
  summary: ...,
  location: ...,
  description: ...,
  start: {
    dateTime: ...,
    timeZone: ...,
  },
  end: {
    dateTime: ...,
    timeZone: ...,
  },
  attendees: [
    {
      email: ...,
    }
  ],
  guestsCanSeeOtherGuests: false,
  guestsCanInviteOthers: false,
  creator: {
    displayName: "Creator Name",
    self: true
  },
  organizer: {
    displayName: "Organizer Name"
  }
};

The event is created as I want, but neither the organizer nor creator properties seem to be applied. The email invite arrives as if it would arrive from the "[email protected]" account.

I have spotted I can change the organizer's name by changing the calendar's name on the UI, but programmatically it doesn't seem to work. Furthermore, the creator's name doesn't want to budge. The creator's name always shows up as "email" or "Email". The service account is impersonating "[email protected]", so I assume the display name is just being taken as the first half of the email.

I have set the name on the UI for the "[email protected]" account, but this name is not used in the email invitation either. There doesn't seem to be anything in the service account settings either to change this name.

I have done a bit of research and found some other people who struggled with similar things:

There doesn't seem to be a definitive answer, however, if there is, and I've just missed it, I am happy to be guided to the right place.

Any help on this would be appreciated.

Upvotes: 1

Views: 467

Answers (1)

Giselle Valladares
Giselle Valladares

Reputation: 2261

I had a similar issue a long time ago, and the creator.displayName documentation only stated that it would show if available, which was confusing.

After that, I found this Google issue tracker, which mentioned that the "if available" was referring to the Google+ profile information. I updated the name inside Google+, and it worked. Since Google+ is no longer available, I will say to try using Currents (which replaced Google+), and it should do the same thing.

You can access Currents here.

Reference:

Upvotes: 1

Related Questions