Google Calendar API view / edit rooms / resources? - google-calendar-api

Is there some way with the Google Calendar API to view which rooms have been booked when retrieving a meeting via the API?
Also is there a way to add a room resource to a meeting via the Calendar API?

The fact that you are using resources with Google calendar tells me that you are a Google Apps for Business/Education user.
If you want a list of resources at your organisation you need to use the Google Apps Calendar Resource API. You can also use this API to create new resources.
If you want to list availability of a calendar resource you need to use the Google Calendar API. You need to query the API using a username that has the appropriate permissions to view the resource calendar. The id of a calendar resource looks like an email address ending in #resource.calendar.google.com
You will also notice that resources are listed amongst your event attendees.
Now the bad news
At the time of writing (October 2013) the Google Apps Calendar Resource API uses Atom/OAuth 1.0a whereas the Google Calendar API version 3 uses JSON/OAuth 2.0.
So that means you currently need to implement two different mechanisms of authentication and two different styles of API, fun eh?
That said since Google are deprecating support for OAuth 1.0a, I'm sure they are beavering away re-writing the Google Apps Calendar Resource API to become JSON/OAuth 2.0 compatible (I may post a question here to ask about that!).
Update
Please see my question for information regarding the lifespan of the Google Apps Calendar Resource API:
Google Apps Calendar Resource API v1 (Atom/OAuth 1.0) likely lifespan?

I've just tried it out - it works fine (returns array of booked dates for each resource id, eventually if such array is empty - resource is available for you. I'd like to get boolean values, but still..)
So, you need to use following API.
Go to section try it
login using oauth
paste request below (Replace resource ids to existing)
Request code:
{
"maxResults": 10,
"timeMin": "2013-11-27T00:00:00+02:00",
"timeMax": "2013-12-27T23:59:59+02:00",
"items": [
{
"id": "RESOURCE_ID_1#resource.calendar.google.com"
},
{
"id": "RESOURCE_ID_2#resource.calendar.google.com"
},
{
"id": "RESOURCE_ID_3#resource.calendar.google.com"
}
]
}

Have you tried querying the free/busy information of the resource (https://developers.google.com/google-apps/calendar/v3/reference/freebusy/query)?
You can update a room resource to a meeting by updating the event
(https://developers.google.com/google-apps/calendar/v3/reference/events/update).
Hopefully, this gives you some good ideas.

Related

Add/update events on my calendar using ASP.NET C# in a webforms app

I need to be able to add/update events on my Google Calendar using ASP.NET C#. I've researched plenty, but am going in circles. I need clarification and direction on what type of authentication is needed, etc.
My webforms app will be used by multiple people. Each person has been granted access to the target calendar. I want the app to make a call to add (and update) events from that app.
My understanding is that I don't need the user's permission to add events to my own calendar that I'm sharing with them. Accurate?
Do I need oAuth, API key or other authentication? Where is clear walk-through code in addition to clarification on credentials needed?
It was stated in the Google Calendar API documentation that:
Every request your application sends to the Google Calendar API must
include an authorization token. The token also identifies your
application to Google.
Also using the method Events: insert, requires authorization. Same with the Events: update. Just make sure you need to add the following scope (https://www.googleapis.com/auth/calendar).
Check the example code snippet of insert and update method.

Google Calendar API Get Events from Other Calendars

I'm extending a PHP application that allows managers to create events and assign specific users to those events. Before the user is listed as available to be assigned, however, I run a check against the user's calendar to see if they are available.
I've already built this once for Exchange using EWS and making use of FindItem method to retrieve events in a given timeframe for a user's email address, but I'm having trouble finding an equivalent in the Google Calendar API.
Both Events and FreeBusy Calls seem to require the specific user's calendarId, which is fine for retrieving the active authenticated manager's Calendar information, but not for their users, of which only the email address is currently available to my system.
Is there a way to retrieve events or a calendarId for a user based on a valid Google email address? (Or is there a better way to get other user's FreeBusy status that I've completely overlooked in my research?)
The Calendar API is a REST API that can be accessed through explicit HTTP calls or via the Google Client Libraries. However, please note that all requests to the Google Calendar API must be authorized by an authenticated user.
User's calendar list can be obtained through HTTP request:
GET https://www.googleapis.com/calendar/v3/users/me/calendarList/calendarId
Code examples for supported programming languages can be found in CalendarList: get.

Accessing Google analytics api using api key

I'm trying to implement Google analytics API using API key to make it available without authorization. But i can get examples using CLIENT ID in google developer console itself. Can anyone help me with an example using api key?
It is not possible to access Google Analytics API with the API key. You must use Open Authentication.
If you are trying to access your own data you can use a service account. Create new credentials choose Service Account.
You can then take the service account email address:
1046123799103-nk421gjc2v8mlr2qnmmqaak04ntb1dbp#developer.gserviceaccount.com
Add it as a user at the ACCOUNT level it is very important that it be at the ACCOUNT level it wont work other wise. Your application with then be able to access your Google Analytics data with out a log in.
Without knowing what language you are working with I cant give you any examples.
Update:
If as you say you are planning on doing this with JavaScript then you will have to go with Oauth2 and request access. There is no way to use a Service account with JavaScript.
There for I strongly recommend that you find a server sided programing language to do this in. Even if it did work with JavaScript you would end up running out of quota on the API before to long.
Google Analytics' EmbedAPI will allow you to display your Google Analytics via javascript, and users will be able to log in on page.
You will still need to get your clientAPI, but then users will be able to login independently.
The javascript code is described in the dev guide and a sample is below:
<script>
gapi.analytics.ready(function() {
// Step 3: Authorize the user.
var CLIENT_ID = 'Insert your client ID here';
gapi.analytics.auth.authorize({
container: 'auth-button',
clientid: CLIENT_ID,
});
</script>
The API limit should be no problem, its 50,000 calls per day.

Using Google Analytics to show subset of data for customers of web application using embed api

I'm developing an application where each 'business' has its own page (or rather many pages):
For example example.com/business/abc/
So, for the logged in business owners in the system I would like to give a feature 'View page analytics'. It would display how many visits (and maybe a couple of other things) that particular page has had.
Is there a way of doing this using the Google Analytics API with my constraints:
I don't want customers to provide their own UA code
I don't want them to require to have GA account
Customers don't need to have Google email account
I don't want to build the entire frontend and backend myself. I would rather use something existing
I've been researching this topic for hours trying to come up with a solution and can't figure out anything.
Here is what I tried and what problems happened to me:
http://ga-dev-tools.appspot.com/demos/embed-api/
This is basically exactly what I want for my customers to be displayed on my site (like in the examples), except that Embed Api tries to authorize users to their own (owned) google analytics. I want it instead to use my own Google Analytics data (or rather part of it)
The way I thought about limiting data access would be for every one of my customers to create a View in GA, Add filter to that View so only customer pages are listed there, assign User to the view, and use the Embed Api to display data from that View only. There are a couple of problems with that:
To assign User to View we need email address. And this must be either google account email, or account from a project created with Google Developers Console (application).
In other words I can't create (in any way that I know) an account that would be a shield account for my customers to a subset of my GA data that they would be interested in. It must be either a real user or a real application email address.
So what I tried to do is... I created an app in Google Developers Console, Created new OAuth Service Account. Using Ruby code (that in production app would be running on backend) I obtained OAuth token. I added this email of my OAuth service account as a User to the View
I wanted this server side generated oauth token to be used by Embed Api. That would achieve the effect that I generate the token for on my backend and user can use it without having GA user in my GA property. So I changed according to documentation the basic Embed Api example to use
gapi.analytics.auth.authorize({
container: 'auth',
clientid: 'xxx.apps.googleusercontent.com',
serverAuth: {
access_token: 'Server side generated token'
}
});
instead of
gapi.analytics.auth.authorize({
container: 'auth',
clientid: 'xxx.apps.googleusercontent.com',
});
The effects are not quite what I expected. The example doesn't show anymore (I can't see my data) but I can see in Netowrking section in Chrome that it is actually receiving real data from GA. But for unknown reason, nothing is appearing.
What I try to avoid is building a solution in which I need to build server side code that is querying GA for data, providing it to the frontend and then JS is responsible for displaying it. I would rather use Embed API but it seems not to be well suited for the use case where I don't want users to play with their UA data but rather with my own UA data limited to some scope. I would like to have at least the frontend or backend part of the solution solved. The solution doesn't need to be even Google Analytics based. Anything else that would let me achieve the use case easily and let the business owners see the effects of their marketing (traffic, sales) would be interesting as well.
Related:
Using google analytics API to show subset of data for customers of web application
Google analytics customer data?
Google Analytics API: filter by URI?
https://embeddedanalytics.com seems like something that could be useful, but their page and graphs look like from a few years ago. I would like something more pretty.
https://oocharts.com seems to be interesting because of what their docs.oocharts.com says about queries. But they don't charge anything for their product so I am skeptical of their business model and whether it is a good long-term solution. update: dead link
I don't have enough karma to post links ;)
TLDR: Displaying subset of my GA data to my customers without forcing them to become GA users and adding them to my GA account.
Any help appreciated!
Without seeing your code it's hard to know where the problem is, but using the serverAuth option definitely works. And when using the serverAuth option, you don't need to specify a client ID or container, all you need to enter is the following:
gapi.analytics.auth.authorize({
serverAuth: {
access_token: 'Server side generated token'
}
});
Here's an example that will work if you enter in a valid access token and the idsfor a view to which you have access:
http://jsbin.com/vukezoheyeco/3/edit
Note: when doing auth like this, it happens sync. This can be a gotcha if you're used to an async auth flow (like normal) and you add an event handler listening for the "success" event after calling .authorize because then your handler will never run.
I think you need the Google Analytics Super Proxy
You download the github package and upload to your own App Engine project, do some minimal configuration and then you have an interface where you can setup Google Analytics API calls which require no user login.
It provides end user URLs that you can use to construct data tables in your front end, it also provides data-table format so it slots right into Google Charts.
So for example, you have a user that needs access to visits, revenue for site section /sectionA/
You set up the GA super proxy to serve them a URL that only includes data for that section - you can try out queries here in the GA query explorer. In this case, metrics=ga:visits,ga:productRevenue and filter~=ga:page=/sectionA/
This produces an end URL with JSON data, that refreshes daily/hourly - your choice. You import this URL into your app.
The end user then logs in to your app, and sees the chart data generated from the end URL for their login. They don't need to know about GA super proxy, they just see the end resulting chart.
You could get more sophisticated by providing dropdowns to select which data chart they see, which changes the GA super proxy URL that is requested.

Google Calendar API v3 404 for Events

I've got a relatively simple task I'm trying to accomplish with the Google Calendar v3 API, but I keep running into 404 errors. I only need to access one calendar (belonging to my client) and get read-only event data via Javascript (just using the protocol with an Ajax call), so I'm trying to avoid using authentication.
I made the calendar public by going to the calendar sharing settings clicking "Share this calendar with others" and then choosing "Make this calendar public. However, the only option I have for public is "See only free/busy (hide details)."
Having realized that, I edited each event to specifically set the type to "public."
Now, I'm able to get a eventList from the calendar resource, but there are only a few details for each item in the array (see below). And, when I try to access the individual event, I get a 404.
Having tried with a basic test calendar, I'm fairly certain the calendar sharing settings are the issue. The main difference between my client's calendar and the test calendar I used is that his calendar is a part of a Google Apps for business account, I'm fairly certain.
Is there any setting in the calendar itself I can edit to make the API work without having to use auth to access the data? Or, is there an option in the business apps settings I can have my client change? Again, I'm talking about only doing GET requests on one specific calendar using Javascript, so authentication is undesirable.
There's really no code I can show here because I'm just grabbing the data via the URI; I have the same problem (the 404) when using the explorer tool in the API docs. However, as you might expect, when I authenticate with that explorer tool, the events appear with no problems.
Sample item from the eventList:
{
"kind": "calendar#event",
"id": "(idremoved)",
"status": "confirmed",
"updated": "2012-05-29T21:06:42.000Z",
"start": {
"dateTime": "2012-06-18T19:00:00-05:00"
},
"end": {
"dateTime": "2012-06-18T21:00:00-05:00"
},
"visibility": "public"
}
I'm using the following to read Google Apps for Education calendars, which has the same api and security restrictions as for Business.
After getting the public calendar address, I decided to parse the full version of the calendar instead of the basic version:
https://www.google.com/calendar/feeds/your_calendar_id_here%40gmail.com/public/full
from what I've seen if your calendar is public, your events will be as well. You will want to make sure that the public for your calendar is accessible in your browser by just pasting the url. Check that events are also public by doing that as well. Make sure that the calendar is public but the "Share only my free/busy information (Hide details)" box is unchecked

Resources