Search code examples
javaspringgoogle-cloud-platformgoogle-oauthgoogle-calendar-api

How can we create event in any email's google calendar through API?


I am creating a project where according to students slots I want to assign a event to their calendar, I have their emails 20-30 of those ,All the emails are random and does not belong to a organization.

How can I create a event on their calendar? I have a service account activated through Google cloud console. I also want to attach meet links to their events?

Does anyone knows an architecture to do this? I want to implement this in java spring boot but just a artitechure will be fine. Thanks


Solution

  • I am creating a project where according to students slots I want to assign a event to their calendar,I have their emails 20-30 of those,All the emails are random and does not belong to a organization.

    I would assume this means that they do not belong to your google workspace domain.

    How can I create a event on their calendar? I have a service account activated through Google cloud console. I also want to attach meet links to their events?

    Service accounts only work with Google calendar if you set up domain wide delegation on the google workspace domain. It will only work with domain email accounts.

    In your case you will need to use Oauth2 and have each user authorize your application to access their calendar then you will be able to create events on their calendar. If you request offline access you can store the refresh token for each user in your system somewhere. Then you will be able to request a new access token when ever you need to acccess their system.

    Note: This is your only option for non domain emails you must have authorization of the user and the only way to get that is though Oauth2.

    Does anyone knows an architecture to do this? I want to implement this in java spring boot but just a architecture will be fine. Thanks

    Check out the google api java client library there are examples for using Oauth2 with Java.