0

I want to add an email address to one of my calendars inside a plugin for wordpress I am building. I am using the following function to do it. The access token is valid, that is not the problem. But I can see that the response to my request is a list of the existing emails in the calendar, instead of a object describing the email I added. And when i check the calendar I can see that the new email was not added. I want to make sure that my jQuery ajax settings are correct. The Google Calendar API doesn't explicitely say how to pass the access token but I saw one example doing it the way I am doing it below. If anyone has used jQuery Ajax to do a Google API request, I would appreciate it if you spot somethiing wrong. Below is the function I am usign to the the ajax request:

function insertACL() {
$.ajax({
  url: 'https://www.googleapis.com/calendar/v3/calendars/[email protected]/acl',
  data: {
    access_token: google_access_token,
    role: 'writer',
      scope: {
        type: "user",
        value: "[email protected]"         
      }
  },
  success: function(resp) {
    var user = resp;
    console.log(user);

  },
  dataType: "jsonp"
});
5
  • Could you specify what you mean by add an email address to one of my calendars? Are you trying to add a user/owner to the calendar (with view/edit permissions), or are you trying to add an email to a specific event? Commented Sep 5, 2017 at 22:53
  • Yes, I want to add user/owner to the calendar so that I can share it with that person. In my code, you can see that this is what I am doing if you look at the " scope: " part of the "data: " section in the ajax call. Commented Sep 5, 2017 at 22:58
  • In that case, I'd recommend this answer, as that covers this topic and comes with some sample code. Commented Sep 5, 2017 at 23:10
  • Possible duplicate of Google Calendar JavaScript api, add user to a calendar with "write" access Commented Sep 5, 2017 at 23:10
  • Thank you but none of the above help. The Jquery Ajax uses a different syntax than the javascript solutions shown there. Would be great to see an example using jQuery Ajax. Commented Sep 5, 2017 at 23:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.