문제

I am trying to play around with the new client libraries for Google API:

https://code.google.com/p/google-api-dotnet-client/

I've downloaded and extracted the sample code: Google API Dotnet Client Sample Solution

I've also setup the necessary API access in: Google Developers Console

But for some reason, I simply cannot get anything to start properly.

As I know there are a lot of samples in the Sample Solution posted above, I'll try to narrow it down first to making just one of the projects run, Plus.ServiceAccount.

After creating a Service Account in the Developer Console and downloading the P12 JSON key, and replacing the one in the project, I am running into the error:

CryptographicException was unhandled (The system cannot find the file specified.)

And the error happens at this line:

var certificate = new X509Certificate2(@"key.p12", "notasecret", X509KeyStorageFlags.Exportable);

I hope someone could provide some kind of a very straightforward example to get things running quickly. I am finding the Google Documentation on using the Client Libraries lacking and inadequate.

Thank you.

도움이 되었습니까?

해결책

I think the issue may be that it can't find your key. Try using Server.MapPath

Server.MapPath("path to key")

or

Store the path to you key file in a variable and pass that as an argument

 string key_file = @"path to key";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top