我正在尝试使用服务帐户将Dynamics CRM软件的日历同步到Google.在此过程中,我遇到了关于.net的谷歌API缺乏文档,特别是关于授权.由于使用了过时的库和类,大多数Google样本都无法编译.
所以我发现了一些关于实习和接收错误的例子.有人可以看看我的样品,告诉我做错了什么?
准备步骤:
然后创建了控制台应用程序并设法安装OAuth和Calendar nuget包.有:
有一个代码可以找到并适应我的需求:
using System;
using System.Security.Cryptography.X509Certificates;
using Google.Apis.Calendar.v3;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
namespace CrmToGoogleCalendar
{
class Program
{
static void Connect()
{
var certificate = new X509Certificate2("My Project-ee7facaa2bb1.p12", "notasecret", X509KeyStorageFlags.Exportable);
var serviceAccountEmail = "506310960175-q2k8hjl141bml57ikufinsh6n8qiu93b@developer.gserviceaccount.com";
var userAccountEmail = "<my email>@gmail.com";
var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
User = userAccountEmail,
Scopes …
Run Code Online (Sandbox Code Playgroud) oauth google-calendar-api google-api google-oauth google-api-dotnet-client