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
- 1 回答
- 0 關注
- 94 瀏覽
添加回答
舉報