【发布时间】:2014-03-10 21:57:23
【问题描述】:
我正在开发一项服务,该服务需要授权服务器到 Google 地图引擎的服务器。
https://developers.google.com/maps-engine/documentation/oauth/serviceaccount 和 https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth?hl=en#service_account 解释了如何执行此操作。
但是,在 Google API 中。 NET,还没有 Google Maps Engine API 的服务类,那么我想参与库的部分流程,因为我不想做所有管理 JWT 的艰苦工作。
我认为是这样的:
var certificate = new X509Certificate2(@"key.p12", "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { "https://www.googleapis.com/auth/mapsengine" }
}.FromCertificate(certificate));
var request = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/mapsengine/v1/projects");
credential.ApplyAuthenticationToRequest(request);
我想使用纯 HttpWebRequest,但是使用证书。
有人可以帮我吗?
亚历克斯
【问题讨论】:
标签: google-oauth x509certificate google-api-dotnet-client google-maps-engine