1

I've created a Windows Console Application that uses the Google Sheets API, following this link and it worked perfectly.

However when I try to build a Windows Service to do the same thing, it freezes at Authorization, presumably because the web page doesn't popup allowing me to authorize it (which makes sense for a Service).

How can I authorize it? The link says

If this fails, copy the URL from the console and manually open it in your browser

which would be great if I knew what the URL was.

mcmillab
  • 2,752
  • 2
  • 23
  • 37
  • You might want to check other scenarios of authenticating your app in the documentation - [Using OAuth 2.0 to Access Google APIs](https://developers.google.com/identity/protocols/OAuth2). Like using service account to authorize your request without any popup to authorize it. Hope this helps. – Mr.Rebot Jan 03 '17 at 14:13

1 Answers1

2

Not a definite answer, but OAuth is designed rather for interactive scenarios involving users.

For service, you should create service account in google developer console and create private key for it (https://developers.google.com/identity/protocols/OAuth2ServiceAccount).

Then you have to change your code to use JWT authentication token derived from private key created in first step.

Someone already answer how to do it in C#: Is there a JSON Web Token (JWT) example in C#?

Community
  • 1
  • 1
Zbigniew Zagórski
  • 1,921
  • 1
  • 13
  • 23