亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Google 日歷與 Google App Engine 的集成

Google 日歷與 Google App Engine 的集成

Go
三國紛爭 2022-05-18 10:08:51
我在 Google 帳戶 A 上設置并運行了 Google App Engine 服務。我想做的是在我的企業的 Google 日歷帳戶 B 上預訂活動。我將此作為一般指南。以下是我為此執行的步驟(注意:AppEngine 已經在運行并且可以正常工作。在我的項目中為 Google 帳戶 A 啟用日歷 API轉到我帳戶 B 的管理控制臺,然后轉到安全性 -> 高級設置 -> 管理 API 客戶端訪問權限,并將范圍授權https://www.googleapis.com/auth/calendar給我的帳戶 A 中我的 App Engine 的服務 ID。Go中的以下代碼注意:在 中getCalendarService,我在這個repo 的README之后使用ADC獲取憑據func getCalendarService() (*calendar.Service, error) {    ctx := context.Background()    return calendar.NewService(ctx, option.WithScopes(calendar.CalendarScope))}// code adapted from https://developers.google.com/calendar/create-events/func bookEvent() {    srv, err := getCalendarService()    if err != nil {logAndPrintError(err)}    event := &calendar.Event{        Summary: "Test Title",        Description: "Lorem ipsum",        Start: &calendar.EventDateTime{            DateTime: "2020-02-12T09:00:00-07:00",            TimeZone: "America/Chicago",        },        End: &calendar.EventDateTime{            DateTime: "2020-02-12T17:00:00-07:00",            TimeZone: "America/Chicago",        },    }    calendarId := "primary"    event, err = srv.Events.Insert(calendarId, event).Do()    if err != nil {        logAndPrintError(err)    }    log.Printf("Event created: %s\n", event.HtmlLink)}當我查看日志和錯誤報告時,沒有錯誤,并且日志顯示以下消息:已創建事件:日歷 URL但是當我復制鏈接并轉到我的 Google 帳戶 B 并加載它時,Google 日歷顯示“找不到請求的事件”。值得一提的是,如果我將 url 加載到 Account A 中,它會說同樣的事情。由于某種原因沒有錯誤,但該事件不起作用。我認為這不是我的代碼中的問題,而是憑據中的問題,但我可能是錯的。
查看完整描述

1 回答

?
慕姐4208626

TA貢獻1852條經驗 獲得超7個贊

如果我沒有記錯的話,

您使用服務帳戶創建日歷事件并將此事件插入到服務帳戶的主日歷中

這可能不是您想要的,相反,如果您想將事件插入到您的主日歷中

  • 您需要將此日歷的 id 指定為calendarId而不是主要的 - 這意味著您事先與服務帳戶共享您的日歷

  • 或者,您使用impersonation,即構建服務帳戶服務,使其充當您(或您的域的另一個用戶指定為ServiceAccountUser


查看完整回答
反對 回復 2022-05-18
  • 1 回答
  • 0 關注
  • 112 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號