-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script cannot access Calendar API (with default oauth key(?)) #87
Comments
Hello @koorg The errors seems not to be caused by APIs not being correctly enabled (it should throw a different one), but by the /*
* ID OF THE CONTACTS EVENTS CALENDAR
*
* Open https://calendar.google.com, in the menu on the left click on the arrow next to the
* the contacts events calendar (which should have a name like 'Birthdays and events'), choose
* 'Calendar settings' and finally look for the "Calendar ID field" (it could be something
* similar to the default value of '#contacts@group.v.calendar.google.com', but also really
* different from it): copy and paste it between the quotes in the next line.
*/ Thank you |
Oh damned. Testing at the moment... aaaand it works like a charm. |
You are welcome @koorg. @baatochan @rowanthorpe Throwing here a little thought I made while solving this issue.
|
Can we somehow predict which users can have a different value than |
...this all looks very familiar :-D |
Seeing that old PR, and this issue, it seems Google must use some transitory setting when (perhaps?) pivoting a software-update into production(?), updating DB schemas(?), or something. If so, then it seems unless we find a different way to access the calendar, someone somewhere will always get hit by this if they are unlucky... |
...to clarify, when I opened that old PR, my calendar settings had changed to |
BTW: @koorg, are you using Google Suite (a.k.a. Google Apps - with custom domain-name)? or just gmail? - I ask because I am on Google Suite, and it would be good to narrow down if this applies only to Google Suite users or not. |
Yeah, that was exactly what I was thinking of: I was going to link that when I received the notification of your comment.
There actually is an API call to list all the calendars of the user (with IDs, names and so on), but the ID has this addressbook/non-addressbook problem and the name changes with the language (and the user can rename it as well), so I see no way to automatically acquire the right calendar. Maybe we could add this check: |
@rowanthorpe not that I know of... I use multiple apps from google but I never heard of Google Suite. |
@GioBonvi https://developers.google.com/apps-script/advanced/calendar could it be a workaround to use "listCalendars" from this page, and select the first one matching "#contacts@" or "@groups.v......." |
@koorg: OK, thanks for reply about Google Suite. So that means this affects all users including gmail users. Perhaps a hybrid of both suggestions would be good. Meaning: to allow explicit configuration of the calendar ID (and to error out if it doesn't match an existing ID, as per @GioBonvi's suggestion), and to also allow the ID to be a special value for those who want it (like e.g. For the case of erroring-out, it would be a good approach to output a meaningful log (and send an alert email) stating something along the lines of:
|
I'd like to point out that I have the address of this calendar as |
Yes, that is exactly the API call I was referencing. I'll try implementing it this afternoon/evening (I'll also do a final check on the approved PRs and merge them). |
Based on what @baatochan just pointed out, I now suspect the |
@rowanthorpe You got it! Selecting "Contacts only" prepends "addressbook" to the calendar id! |
BTW: If it is possible to lookup a calendar by its description(?) then there is a non-ambiguous way to do it - users can't edit the description. If the API allows looking up the description with a forced locale, then it could just be looked up as English, and there wouldn't even be a need to worry about parsing different translations. Of course, if the user wants to be a smartass and create their own calendar with the exact same description, then obviously they are trying to break the script, and we wouldn't need to cater to that edge-case. |
@rowanthorpe Indeed, I changed some Calendar settings. But at first I had default settings with English(US) lang set, and the script didn't seem to work, and Calendar ID seemed to be the default one without addressbook#. "display birthday from == Contacts only" => Calendar ID == "addressbook#contacts@group.v.calendar.google.com" |
Oh yeah, I use "contacts only" setting as well :) I haven't thought it could be that. So if that's a case maybe we can set the script to test the calendar that is provided in |
I still think the hybrid-idea of (1)heuristic, or (2)explicit-with-existing-ids-check, and email-a-warning-on-error is worth implementing, so we can handle (A) people who like to opt-in to explicit-mode for security-reasons, and (B) the next naming-change Google makes in the future. Our discovery about the cause of the addressbook prefix, just allows us to use better defaults. On another note - perhaps a lot of "optional Google+" handling could be removed from the script by instead getting that "Google+ & Contacts" vs. "Contacts only" setting via API (if possible), and acting according to that...? |
I'm not a fan of this idea - even though I use 'contacts only' setting I still want those contacts that are in my list to have data from G+. |
@baatochan Ah, OK. Fair point. We should accommodate that use-case. |
Sadly it seems that noone else had this issue before (open/closed issues)...
I cross-checked the set-up and it seems that I have a strange case with the script trying to access the Calendar (yeah it feels like deja-vu)
Steps to reproduce
What action or series of actions is the cause of the issue?
Expected behavior
Receiving a notification
Current behavior
Error: Contacts events calendar not found! Please follow the instructions (step "Enable the calendar"). (line 551, file "Code")
Context
When script in being edited : menu Resources -> Advanced Google Services
Calendar API (v3) in enabled
Going to Google API Console shows "Google Calendar API" enabled, with no activity.
Entering the Google Calendar API settings, the drop-down "all API identifiers" shows the "oauth" script URL enabled under the title "Apps Script" type "ID for Web App" with a callback URL of https://script.google.com/oauthcallback
BUT there is a banner on top of the Calendar API page that says "to use this API you need to create identifiers" and the drop-down documentation says it needs an API key...
I tried to create an API key and enable it for the Calendar API, but it doesn't seem I can have the script use it...
I tried to enable the Contacts API for a comparison, and it takes the oauth key by default (like the Calendar API) but doesn't display the "you need an API key" banner. I disabled it afterwards because it doesn't seem to be required to run the script.
Thanks for any help !!
The text was updated successfully, but these errors were encountered: