-1

Using Google apis with OAuth 2.0, Google recommends using an HttpListener for desktop apps with a note in the documentation that you may run into firewall issues. How is this implemented in their code (GoogleWebAuthorizationBroker.AuthorizeAsync), and what possible issues may arise. For example admin rights, firewall issues - will I encounter these if I use their client library?

Mike Turner
  • 471
  • 1
  • 7
  • 22

1 Answers1

1

The local code receiver listener for the full .NET framework (desktop) starts at LocalServerCodeReceiver.cs line 374.

In v1.26+ of the library it listens on http://127.0.0.1 on a random unused non-privileged port; see line 47.

This shouldn't cause any problems with user rights, or firewalls. However, not knowing how your machines are configured means I can't be completely certain of this.

Chris
  • 1,685
  • 10
  • 15
  • Can you list any cases that would cause a problem with user rights or firewalls? – Mike Turner Jun 05 '17 at 01:27
  • Does this work in windows 8.1? it seems Microsoft has Everyone granted to use 127.0.0.1 in Win10 but not 8.1 – Mike Turner Jun 05 '17 at 14:04
  • Do you mean a windows 8.1 app? That is, targeting the win81 TFM? Or a desktop .NET application that happens to be running on Windows 8? I don't know much about Windows permissions, but if it's a desktop app, and the user is not allowed to use 127.0.0.1, then I expect this cannot and will not work. I can't think of an immediate work-around. You could use something like [PromptCodeReceiver.cs](https://github.com/google/google-api-dotnet-client/blob/master/Src/Support/Google.Apis.Auth/OAuth2/PromptCodeReceiver.cs), but it's a bit crude. – Chris Jun 05 '17 at 18:14
  • @Chris Interesting code here. Can you explain which of the gmail api code is open source, which comes from google? Where's the detailed docs for each? Or do you just read the open source. –  Jun 08 '17 at 02:27
  • @SOS All the code in nuget packages: Google.Apis.Gmail.v1, Google.Apis.Auth, Google.Apis, and Google.Apis.Core is provided by Google and is open source in the [google/google-api-dotnet-client](https://github.com/google/google-api-dotnet-client) github repo. I'm one of the maintainers of this code, so know the code fairly well. – Chris Jun 08 '17 at 07:06
  • @Chris But how do I learn how to use this? Is there clear detailed explanations somewhere? For ex - in docs I see that message.payload.headers contains RFC 2822 email headers, where do I see exactly what is going to be there? The best way to get the subject? The best way to make multiple batch requests to get all message details? I'm supposed to go back to the source code? –  Jun 08 '17 at 14:10