How to access domain users' calendar using service account in .net?

后端 未结 2 1467
旧时难觅i
旧时难觅i 2021-01-03 14:42

I am using service account with key.p12 cert to access google calendar API. However, it cannot access any user\'s calendar in the domain. I did follow the steps to Delegatin

相关标签:
2条回答
  • 2021-01-03 14:51

    Actually, the code should use service account to "impersonate" the domain users one by one, rather than trying to share calendars with service account.

        ServiceAccountCredential.Initializer(serviceAccountEmail)
        {
            Scopes = new[] { CalendarService.Scope.Calendar },
            User = "myaccount@mydomain.com" // impersonate domain user
        }.FromCertificate(certificate));
    

    Also need follow the steps for Delegating domain-wide authority to the service account in google domain admin console, and add the right scope( for calendar, it is https://www.googleapis.com/auth/calendar )

    0 讨论(0)
  • 2021-01-03 14:54

    As you pointed out, you need to share the existing calendar with the service account

    <paste-your-account-here>@developer.gserviceaccount.com
    

    (You can find the account in question under the credentials tab in Google Developers Console, it's called 'EMAIL ADDRESS')

    Hope it helps.

    0 讨论(0)
提交回复
热议问题