Google Service Account with Aspnet MVC Behind A Proxy
Recently I had a fun project to attach google analytics data to an internal site which took longer complete than I thought intial thought but now I could complete in just a day. My biggest issue was finding out the issue was related to the company's proxy. Which I quickly fixed by just added the following snippet at the bottom of this article. For everything else this is just my notes and things I found to help me drill down into the queries for grabbing the data.
Behind a Company Firewall
Resource
How to query Google Analytics in C# | blog.kateo.pl
Using OAuth 2.0 for Server to Server Applications
OAuth 2.0 for Google Apps Service Accounts (installed and web applications) - Great tutorial
Questions
- How to get the Access Token for GA? - Credential.RequestAccessTokenAsync
- Querying example - Use Google Analytics API to show information in C# - Stack Overflow
Behind a Company Firewall
Both errors I encountered were "No connection could be made because the target machine actively refused it 172.217.1.77:443" and “requested service '…' could not be activated” the first time it's accessed".
<system.net> <defaultProxy useDefaultCredentials="true"> <proxy proxyaddress="proxyaddress" usesystemdefault="False"/> </defaultProxy> </system.net>
Resource
How to query Google Analytics in C# | blog.kateo.pl
Using OAuth 2.0 for Server to Server Applications
OAuth 2.0 for Google Apps Service Accounts (installed and web applications) - Great tutorial