简体   繁体   中英

Microsoft Graph for reading my own calendar in C#?

I am not an expert on all things Azure, but I'd like to read my own calendar programmatically. I found some code to access Microsoft Graph and read my calendar, but it seems I have to create an App Registration first, is it possible to SKIP the app registration if I only need to read my OWN calendar? here's my starting point:

var scopes = new[] { "User.Read" };
var options = new TokenCredentialOptions
{
    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};

var userName = "myaccount@company.com";
var password = "pwdhere";

var userNamePasswordCredential = new UsernamePasswordCredential(
    userName, password, tenantId, clientId, options);

var graphClient = new GraphServiceClient(userNamePasswordCredential, scopes);   

var events = await graphClient.Me.Calendar.Events
    .Request()
    .Filter("startsWith(subject,'All')")
    .GetAsync();

您需要注册应用程序,否则您甚至无法登录。如果它是您无法控制的 Azure AD,例如您的雇主,则需要让管理员为您创建。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM