google calendar create event without user logging in - events

Is it possible to create an event on behalf of my own application?
I tried using API Key but that doesn't work. I want all the event to be under my app's account. I don't want to make the user login. I just want to create new google Meet links.

No you must be authorized to write to a users calendar
if you check the documentation for events.insert you will notice a section called authorization
This section tells you what authorization scopes you need in order to be able to write to a users google calendar. A user must grant your application access to their data before your application will be able to write to it.
API keys are only used for accessing public data, for example the public google calendar holiday calendars you can read from them with an api key.
However to access private user data you need to be authorized.

Related

Google API Authentication for App That Only Accesses One Account

Should I use a Service Account or an OAuth 2.0 Client ID?
I'm struggling to understand Google's documentation on authenticating for their APIs. I'm creating a basic application that will help users add and modify Google Calendar events for a single Google account (the account is shared between all users). I only need the application to access that one account, it'll never need to access any others.
It seems to me that Service Account would be best for this, but Google's documentation suggests Service Accounts should only be used for automated processes (unless I'm misunderstanding). For instance this page contains the following, describing when to use Service Accounts.
Would my application qualify as acting on the users behalf?
If so, I would want to use OAuth Client ID credentials, which will ask the user to sign in to a google account. In this case, is there a way I can guarantee they only sign in to the one account I want modified?
I can't find any decent documentation on the OAuth authentication requests to figure this out myself. If there is any could you point me there?
I'm sure I'm misunderstanding something basic here, but thank you for any help!
First off you should know that you can only use service accounts with Google aclendar api if you have a google workspace domain account.
You can then set up a calendar and a domain user that the service account can act on behalf of to control the access of that calendar.
Assuming that your application is going to preform all actions on this calendar then yes i would say that you could use a service account for this. If your app bacly has a ui with a calendar on it your just using google calendar to store the data.
However if you intend to share this calendar with the users themselves, this way they could see it within their own google Calendar account. Im not sure a service account would be the way to go.
If you want the users to be able to see it and make changes then you may want to just use Oauth2. Grant them access to the calendar and then request access to their calendar account.
Drawback to that option is going to be the verification process. You will get access to all the users calendars and your going to need write access.
If you can go with a service account you really should consider it it will save you a lot of hassle with verification.

Youtube API key created by admin?

Is it possible to generate a Youtube API key having admin access to the Youtube account? or is this function only possible for account owners?
Anyone can create a project on Google cloud console You do not need to be an admin on anything to create an api key.
You should understand though that Api keys are used to access public data via the YouTube api. This has nothing to do with a specific YouTube account. It will just let you access the public methods like Video.Search
All methods that require authorization For example members.list show in their documentation page that they require authorization.
The only authorization method allowed for the YouTube api is Oauth2. Someone with access to the channel will need to authorize your application and grant consent that your application access their YouTube channel on their behalf.
The documentation here does not state you can do it having admin access to the YouTube account only. But instead you need access to the actual Google Account linked to the Youtube Channel in question.
If you do have a Google Workspace subscription and the owner of the channel is one of your managed accounts, then you can access the GCP console and proceed with steps in the documentation to generate the key.

Is there a way to get google calendar events by passing email and password dynamically?

In my application ,users have their own accounts ,when a user logs in and provides gmail credentials, i have to get the events in his calendar by making call to calendar API using service account .
There is an api for accessing Google Calendar as you have noted it is called Google Calendar API.
In order to access private user data you must have the owner of that data's permission. To get that permission you use Oauth2.
Accessing APIs using login and password is called client login and this was discontinued by Google around may 2015
Answer: No you can not access a users private Google Calendar data using their login and password.

Google Calendar API for multiple users:

I am developing a web app in Ruby on Rails for registering talks given in my company. If a user registers for a talk, then it should update the Google Calendar event for all users who have the event on their Google Calendar.
https://developers.google.com/accounts/docs/OAuth2
I need to use OAuth2 since I need to modify the user's data and I need to obtain the consent from the user as well. So I can redirect them to the Authentication page where they can sign in to view their account. But in this case the user data I want to modify is Calendar of all those people who signed up for the event.
Is there any easy way to do this? Like using an admin account?
When you want to update the Google Calendar event for all users who already have event in their calendar, you no need to use OAUTH as user authentication is not required.
This is because, when there is an update in the existing event then all the users (who are all already added as attendee in the existing event) calendar gets updated without users consent screen.

add calendar to another user's calendar list

Not sure if this is possible or if anyone has managed to do this. I have user with super admin access, with which I can create a new user for my domain. However I also want to add a couple of calenders to the created user's calendar list. When I create a user I authenticate using my super admin, but then I can't add a calendar to the user's calendar list since I am not logged in as the user. Is it possible to do this as the super admin, or do I have to logout and authenticate as the created user in order to add calendars to their list? This is the base url to which the post request is made:
https://www.googleapis.com/calendar/v3/users/me/calendarList
in the place of me could I pass in the id of the user? I couldn't find any parameter in the documentation with which I can specify the user to whose list I want to add a calender.
Thanks
Two options:
Each user much login to google calendar and share thier calendar to a single user. You can then use this account to update their calendars. Note that google has limitations to how many calendars and request you are allowed before the account goes to read-only mode.
Buy a google apps domain (5$per user per month) and create a service account at console.developers.google.com. Create a project and give it domain wide delgation at admin.google.com. In Apps engine you should be able to give access for admin to modify all users calendars.
No matter what case you choose, you also need to enable CalendarAPI at dev console site. Now with private key created from website request OAuth2 access token, where sub field is set for the users that you want to change calendar for. With returned access token use CalendarAPI to modify calendar.
Sry for bad english and short description, i'm in a hurry. /conner ;)

Resources