0

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...

最後のコメントアウト行を実行すると、作成したエントリが表示されます...しかし、Googleの連絡先に移動してディレクトリをクリックすると、そこにはありません。また、メールを作成するときにオートコンプリートではありません...属性がどこかにありませんか。

エントリを 24 時間以上残しました (金曜日に作成しました)。

任意の入力をいただければ幸いです。

4

1 に答える 1