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

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

帶有 ASP.NET 的 Google 日歷 API

帶有 ASP.NET 的 Google 日歷 API

C#
慕村9548890 2022-07-10 16:01:06
我對使用 Google 日歷 API 在 ASP.NET 網絡表單(C#)中添加/修改事件感到困惑。我不確定我是否需要 oAuth 或什么。我的應用程序在我自己的服務器上訪問我自己的域和我自己的日歷。我不需要其他用戶允許我訪問他們的日歷;我只需要通過我的應用程序訪問我自己的。在我的一個 aspx 頁面上,我想將事件信息發送到我的 Google 日歷以添加(或稍后修改)該事件。我檢查了各種代碼示例和 Google 入門指南。我只是不清楚到底需要什么。我已經設置了一個 API 密鑰和一個 oAuth2 客戶端 ID。谷歌的指示讓我轉了一圈,這可能是因為我需要澄清需要什么。有人可以消除我的困惑并指出我正確的方向嗎?
查看完整描述

1 回答

?
天涯盡頭無女友

TA貢獻1831條經驗 獲得超9個贊

概括 :

  • 調用谷歌云 oauth2 保護資源

  • 從您的服務器到谷歌服務器

  • 無需用戶交互

  • 訪問您自己的數據

  • 使用 C#

代碼 :

    var private_key = @"-----BEGIN PRIVATE KEY-ccc-END PRIVATE KEY-----\n";

    string calendarId = @"[email protected]";

    var client_email = @"[email protected]";


    var credential =

        new ServiceAccountCredential(

        new ServiceAccountCredential.Initializer(client_email)

        {

            Scopes = new string[] { CalendarService.Scope.Calendar }

        }.FromPrivateKey(private_key));

    var service = new CalendarService(new BaseClientService.Initializer()

    {

        HttpClientInitializer = credential,

    });

  • 使用服務方法獲取數據

  • 可以從此鏈接生成私鑰和 client_email

  • 日歷 ID 可在 calendar.google.com 上找到

  • 您必須與 client_email 共享您的日歷查看演示

  Google            You                             You

  Pay +             Pay +                           Pay +

  Google            Google                          You

  Manage            Manage                          Manage%

 +----------+    +----------+                     +----------+

 | Gmail    |    |          |                     |          |

 | Calendar |    |  G Suite |                     | Google   |

 | drive    |    |          |                     | Cloud    |

 |          |    |          |                     |          |

 +----^-----+    +----+-----+                     +------+---+

      |               ^                                  ^

      |               |                                  |

      |               |                                  |

      |               |                                  |

+-------------------------------------------------------------+

|     |               |                                  |    |

|     |               |                                  |    |

|     |               |       Google                     |    |

|     |               |       Oauth2                     |    |

|     |               |       Server                     |    |

|     |               |                                  |    |

|     |               |                                  |    |

+-------------------------------------------------------------+

      |               |                                  |

      |               |         +----------------+       |

      |               |         |                |       |

      |               |         |                |       | No

      |               |require  |                |       | Consent

      |               |admin    |                |       |

      |               |consent  |                |       |

      |require        |         |                +-------+

      |user           |         |                |

      |consent        +---------+   Your app     |

      |                         |                |

      |                         |                |

      |                         |                |

      |                         |                |

      +-------------------------+                |

                                |                |

                                |                |

                                |                |

                                +----------------+

                                     You

                                     Pay +

                                     You

                                     Manage

https://stackoverflow.com/questions/54066564/google-calendar-api-with-asp-net

查看完整回答
反對 回復 2022-07-10
  • 1 回答
  • 0 關注
  • 94 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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