我嘗試使用Google Admin API-sdk進行身份驗證但是,我們收到了一些應由Dll創建的文件錯誤錯誤,我們正在使用。 即使在閱讀了許多文章之後添加了所有推薦的dll之後,我仍然會接受這一點。這是我使用的代碼。使用Google Admin SDK的Google用戶帳戶c# - Google.Apis.Admin.Directory.directory_v1.cs找不到
protected void Page_Load(object sender, EventArgs e)
{
const string serviceAccountEmail = "<id>@developer.gserviceaccount.com";
const string serviceAccountCertPath = @"E:\Test.p12";
const string serviceAccountCertPassword = "notasecret";
const string userEmail = "[email protected]";
var certificate = new X509Certificate2(serviceAccountCertPath, serviceAccountCertPassword, X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser },
User = userEmail
}.FromCertificate(certificate));
var service = new DirectoryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "User Provisioning",
});
User newuserbody = new User();
UserName newusername = new UserName();
newuserbody.PrimaryEmail = "[email protected]";
newusername.GivenName = "Harsh";
newusername.FamilyName = "Sharma";
newuserbody.Name = newusername;
newuserbody.Password = "[email protected]";
User results = service.Users.Insert(newuserbody).Execute();
}
}
}
我使用新的用戶配置,但同時這個認證得到了失敗的調試由於沒有找到Google.Apis.Admin.Directory.directory_v1.cs此代碼。請有人讓我知道要獲取Google.Apis.Admin.Directory.directory_v1.cs文件。我知道我已經添加了所有添加的dll。 是我使用的命名空間如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Util.Store;
using Google.Apis.Admin.Directory.directory_v1;
using Google.Apis.Admin.Directory.directory_v1.Data;
using DotNetOpenAuth.GoogleOAuth2;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using Google.Apis.Auth.OAuth2.Requests;
using Google.Apis.Auth.OAuth2.Responses;
這個https://code.google.com/p/google-api-dotnet-client/source/browse/Services/Google.Apis.Admin.directory_v1.cs?repo=samples&r=498cff20b5880f3fbebd1aeac9acafda4d1c3ce3也許? – Emily 2014-10-28 23:09:25
你有沒有把所有的參考文獻設置爲複製本地真實? – DaImTo 2014-10-29 08:30:07