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
Related
I am working on Google Apps script that will list all Out of office events from the calendar of someone from my organization.
Calendar is made available for my organization, but limited to free/busy data (and I cannot change the sharing settings). The Out of office events are public by default, so when I open someones calendar in the Calendar application, I can see the out of office events. I am not able to do it using API.
Any ideas? :)
I tried:
let currentCalendar = CalendarApp.getCalendarById("someone#organization.com"); - returns null
response = Calendar.Events.list("someone#organization.com", params); - returns response with empty collection of events and accessRole: "freeBusyReader".
I have implemented a solution in our application to send certain events to Facebook Pixel via Conversions API. We are not using the Pixel JS code in our application. All events are sent from the server. We get the Pixel Id and Access Token from the customer and fbclid from the url. We use this data to send events using the Facebook Business SDK.
The events are being sent successfully and the events show up in the Events Manager.
However, the events are not assigned to the Campaigns which use the same Pixel. Has anyone faced this issue before? Please help if someone know the cause for this.
Sample data that we send via the SDK to Facebook.
{
"data": [
{
"event_name": "Lead",
"event_time": 1662450937,
"action_source": "chat",
"event_source_url": "https://test.test",
"user_data": {
"fbc": "fb.1.1662386239929.IwAR3NTvPLLPmv9FrKx9tmW1VL_NGjC9CmxxjZJQH5OPke0C2BH2AsldF1M"
}
}
]
}
I would like to now if the following functionality is supported by google calendar api:
Does the functionality provided by "Push notifications" include new events or just existing ones. Here is a copy paste from the documentation that let me doubt that new event notifications are supported "The Google Calendar API provides push notifications that let you watch for changes to resources.". So does this only apply to already existing resources (events on my case).
Is there a way to limit the availability on the google calendar. By this I mean setting a general limit (i.e working hours for a company for example from 9am to 5pm). And putting the logic further, is there a way to add more constraints. For example after I receive a notification of a new event created (if this functionality is provided), I check the event's data in my web-hook and let google calendar know that this event shouldn't be considered as valid.
If these requirements are not provided already by google calendar API, I am open to any suggestions to accomplish this even if it takes more coding.
Just to make it clear. The context of these questions is when the user creates an event in their google calendar through google calendar web interface not through my application.
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.
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.