C# 谷歌共享联系人-不出现在目录中

C# 谷歌共享联系人-不出现在目录中,c#,google-shared-contacts,C#,Google Shared Contacts,我正在google中创建共享联系人,它创建了联系人,但我在google联系人目录中看不到联系人 我一直在寻找答案,可能找到了最接近的答案。。但我似乎不能把它弄对 下面是一些代码: string s = "https://www.google.com/m8/feeds"; string targetUri = @"https://www.google.com/m8/feeds/contacts/mycompany.com/full"; string servic

我正在google中创建共享联系人,它创建了联系人,但我在google联系人目录中看不到联系人

我一直在寻找答案,可能找到了最接近的答案。。但我似乎不能把它弄对

下面是一些代码:

    string s = "https://www.google.com/m8/feeds";
string targetUri = @"https://www.google.com/m8/feeds/contacts/mycompany.com/full";          
    string serviceAccountEmail = "123456789012-xxxx1x1xx11x1xxxxxxx11xxxx1xxx11@developer.gserviceaccount.com";
    string serviceClientId = "123456789012-xxxx1x1xx11x1xxxxxxx11xxxx1xxx11.apps.googleusercontent.com";
    X509Certificate2 certificate = new X509Certificate2(@"C:\All\mygcertificate-1xx1xxx1xx11.p12", "notasecret", X509KeyStorageFlags.Exportable);

    ServiceAccountCredential credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
    {
        Scopes = new[]
    {
        "http://www.google.com/m8/feeds/contacts/"
    },
        User = "my.user@mycompany.com"
    }.FromCertificate(certificate));


    string AuthenticationToken1 = string.Empty;
    if (credential.RequestAccessTokenAsync(CancellationToken.None).Result)
    {
        AuthenticationToken1 = credential.Token.AccessToken;
    }

    Service service = new Service(s, serviceClientId);

     GAuthSubRequestFactory factory = new GAuthSubRequestFactory(s, serviceClientId);
    factory.Token = AuthenticationToken1;
    service.RequestFactory = factory;


    Contact ct = new Contact();
    ct.Name = new Google.GData.Extensions.Name() { GivenName = "Ron", FamilyName = "Swanson", FullName = "Ron Swanson" };
    ct.Emails.Add(new Google.GData.Extensions.EMail("Ron.Swanson@someclient.com", @"http://schemas.google.com/g/2005#work") { Primary = true });
    ct.Phonenumbers.Add(new Google.GData.Extensions.PhoneNumber("2345555522") { Rel = @"http://schemas.google.com/g/2005#work", Primary = true});
    AtomCategory atc = new AtomCategory();
    atc.Term = @"http://schemas.google.com/contact/2008#contact";
    atc.Scheme = @"http://schemas.google.com/g/2005#kind";
    ct.Categories.Add(atc);


    var atomentrytoinsert = ct.AtomEntry;

    var result = service.Insert(new Uri(targetUri), atomentrytoinsert);

    //Stream getresult = service.Query(new Uri(targetUri)); //this read actually gets the records i inserted...
如果我运行最后一行注释,我可以看到我创建的条目。。。但当我转到谷歌联系人并点击目录时,他们不在那里。当我撰写电子邮件时,也不是在自动完成上。。。我是否在某个地方遗漏了一个属性

我已经留下了超过24小时的条目(我在周五创建了它们)


如果您有任何意见,我将不胜感激。

我昨天尝试了sharedcontact API,新联系人在目录中不可见

但是今天早上,自动完成提示了新的联系人!为了使它们在目录中可见,我必须打开管理谷歌控制台->谷歌应用->联系人->高级设置,并选中“显示域的两个配置文件都是域共享联系人”

它立即为我工作,我希望帮助你