Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google app engine 谷歌日历与谷歌应用引擎的集成_Google App Engine_Go_Google Cloud Platform_Google Calendar Api - Fatal编程技术网

Google app engine 谷歌日历与谷歌应用引擎的集成

Google app engine 谷歌日历与谷歌应用引擎的集成,google-app-engine,go,google-cloud-platform,google-calendar-api,Google App Engine,Go,Google Cloud Platform,Google Calendar Api,我有一个谷歌应用程序引擎服务,在谷歌帐户a上设置和运行。我希望能够做的是在我的企业的谷歌日历帐户B上预订活动。我遵循作为一般指南。以下是我为此所做的步骤(注意:AppEngine已经在运行并正常工作 在我的项目中为Google帐户A启用日历API 转到我的帐户B,转到安全->高级设置->管理API客户端访问并授权范围https://www.googleapis.com/auth/calendar帐户A中我的应用程序引擎的我的服务id 下面是围棋中的代码 注意:在getCalendarServic

我有一个谷歌应用程序引擎服务,在谷歌帐户a上设置和运行。我希望能够做的是在我的企业的谷歌日历帐户B上预订活动。我遵循作为一般指南。以下是我为此所做的步骤(注意:AppEngine已经在运行并正常工作

  • 在我的项目中为Google帐户A启用日历API
  • 转到我的帐户B,转到安全->高级设置->管理API客户端访问并授权范围
    https://www.googleapis.com/auth/calendar
    帐户A中我的应用程序引擎的我的服务id
  • 下面是围棋中的代码
  • 注意:在
    getCalendarService
    中,我使用以下自述文件获取凭据

    func getCalendarService()(*calendar.Service,错误){
    ctx:=context.Background()
    return calendar.NewService(ctx,option.WithScopes(calendar.CalendarScope))
    }
    //代码改编自https://developers.google.com/calendar/create-events/
    func bookEvent(){
    srv,err:=getCalendarService()
    如果err!=nil{logAndPrintError(err)}
    事件:=&calendar.event{
    总结:“测试标题”,
    描述:“Lorem ipsum”,
    开始:&calendar.EventDateTime{
    日期时间:“2020-02-12T09:00:00-07:00”,
    时区:“美国/芝加哥”,
    },
    结束:&calendar.EventDateTime{
    日期时间:“2020-02-12T17:00:00-07:00”,
    时区:“美国/芝加哥”,
    },
    }
    calendarId:=“主要”
    event,err=srv.Events.Insert(calendarId,event.Do())
    如果错误!=零{
    logAndPrintError(错误)
    }
    log.Printf(“创建的事件:%s\n”,Event.htmlink)
    }
    
    当我查看日志和错误报告时,没有错误,日志显示以下消息:

    创建的事件:日历URL

    但是,当我复制链接并转到我的Google帐户B并加载它时,Google Calendar会说“找不到请求的事件”。值得一提的是,如果我将url加载到帐户A,它会说同样的话

    由于某些原因,没有错误,但事件不起作用。我认为这不是我的代码中的问题,而是凭据中的问题,但我可能错了


    注意:我没有下载任何密钥,我正在使用ADC和App Engine获取我的凭据。

    如果我没有弄错

    您正在使用服务帐户创建日历事件并插入 将事件添加到服务帐户的主日历中

    如果您想将事件插入主日历,这可能不是您想要的

    • 您需要将此日历的id指定为
      calendarId
      ,而不是主日历-这意味着您需要事先与服务帐户共享日历
    • 或者,您使用,即构建服务帐户服务,使其充当您(或指定为
      ServiceAccountUser

    在我的问题中,我说我在设置模拟链接时遵循了该链接作为指导。我可以做什么不同的事情?谢谢你的帮助。你能提供包含创建包括模拟在内的服务的代码片段吗?你是否编写了与之等效但使用你的语言(go)的代码?我不太熟悉App Engine,但请看一看。指定您模拟的用户很重要,因为该事件将在该用户的日历中创建。非常感谢您的帮助。我将尝试您所说的内容,并在其运行后进行投票并接受。