I'm trying to use the latest .NET client libraries to access Version 3.0 of the Google Analytics API (Core Reporting API). I registered my application in the Google APIs Console and used OAuth 2.0 for accessing the API.
Since there are no samples yet how to use the Google Analytics API, I used a sample that demonstrates the simplest use case for an OAuth2 service and applied that schema to my context - with success.
(Remark: I also found help to correct the mistakes in the source code of the library Google.Apis.Analytics.v3.dll)
If I use my program, I am required to login to Google, to grant permissions to my application and to copy an authorization code.
I would like to skip this flow by writing my login password into the program code (- in clear text). My problem ist that I can't find this feature in the libraries. In Google Analyitcs Version 2.3, it did work with the simple C# lines:
AnalyticsService asv = new AnalyticsService("");
asv.setUserCredentials(CLIENT_USERNAME, CLIENT_PASS);
Can anybody help me?
Putting in a username and password is a security issue. Google added offline access just for this purpose.
Use a refresh token. You can store that and use it to access your analytics data without having to log in every time which is essentially what you are doing with the username and password set up you described.
Offline access instructions can be found here:
http://code.google.com/apis/accounts/docs/OAuth2WebServer.html#offline
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With