未从 Google 获取私人日历活动
Not getting private calendar events from Google
我想从 Google 日历中导入所有事件。在我的代码中,我将首先对用户进行身份验证。用户成功登录后,我将使用 GET 请求在下面调用 API。
https://www.googleapis.com/calendar/v3/calendars/my Email/events?key=my App Key&fields=items(id,start,summary,status,end)
我正在收到回复
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
一旦我将我的日历更改为 public,它将提供所有事件的详细信息,但如果日历被标记为私人,那么它会给出上述响应。
有人知道如何从私人日历中获取活动详情吗?
我认为您可能需要添加访问令牌才能访问您的日历信息,如果您使用 JavaScript 库,您可以查看这些示例:
https://developers.google.com/api-client-library/javascript/features/authentication
我已经使用 Angular JS + Ionic(使用 REST API)实现了 getCalendar
https://developers.google.com/google-apps/calendar/v3/reference/
,不过我现在在上班,需要的话稍后发给你。
看看这个例子,您可能会明白如何将您的请求令牌附加到您的请求中:
ionicExample.controller("DigitalOceanExample", function($scope, $http, $cordovaOauth) {
$scope.digitalOceanLogin = function() {
$cordovaOauth.digitalOcean("CLIENT_ID_HERE", "CLIENT_SECRET_HERE").then(function(result) {
window.localStorage.setItem("access_token", result.access_token);
}, function(error) {
console.log(error);
});
}
$scope.getDroplets = function() {
$http.defaults.headers.common.Authorization = "Bearer " + window.localStorage.getItem("access_token");
$http.get("https://api.digitalocean.com/v2/droplets")
.success(function(data) {
console.log(JSON.stringify(data.droplets));
})
.error(function(error) {
console.log(error);
});
}
});
我从这个 Google 开发者控制台
得到了解决方案
我想从 Google 日历中导入所有事件。在我的代码中,我将首先对用户进行身份验证。用户成功登录后,我将使用 GET 请求在下面调用 API。
https://www.googleapis.com/calendar/v3/calendars/my Email/events?key=my App Key&fields=items(id,start,summary,status,end)
我正在收到回复
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "Not Found"
}
],
"code": 404,
"message": "Not Found"
}
}
一旦我将我的日历更改为 public,它将提供所有事件的详细信息,但如果日历被标记为私人,那么它会给出上述响应。
有人知道如何从私人日历中获取活动详情吗?
我认为您可能需要添加访问令牌才能访问您的日历信息,如果您使用 JavaScript 库,您可以查看这些示例: https://developers.google.com/api-client-library/javascript/features/authentication
我已经使用 Angular JS + Ionic(使用 REST API)实现了 getCalendar
https://developers.google.com/google-apps/calendar/v3/reference/ ,不过我现在在上班,需要的话稍后发给你。
看看这个例子,您可能会明白如何将您的请求令牌附加到您的请求中:
ionicExample.controller("DigitalOceanExample", function($scope, $http, $cordovaOauth) {
$scope.digitalOceanLogin = function() {
$cordovaOauth.digitalOcean("CLIENT_ID_HERE", "CLIENT_SECRET_HERE").then(function(result) {
window.localStorage.setItem("access_token", result.access_token);
}, function(error) {
console.log(error);
});
}
$scope.getDroplets = function() {
$http.defaults.headers.common.Authorization = "Bearer " + window.localStorage.getItem("access_token");
$http.get("https://api.digitalocean.com/v2/droplets")
.success(function(data) {
console.log(JSON.stringify(data.droplets));
})
.error(function(error) {
console.log(error);
});
}
});
我从这个 Google 开发者控制台
得到了解决方案