Google Analytics .net api OAuth compile error

genapreved

New Member
I am trying to write some code that gets the Google Analytics data via the .net/c# api from Google,I use the following topic to get started: stack overflow threadand wrote the following code\[code\]using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Data.SqlTypes;using System.Security.Cryptography.X509Certificates;using Google.Apis.Authentication.OAuth2;using DotNetOpenAuth.OAuth2;using Google.Apis.Analytics.v3;namespace ManagementAPI.Models{public class Value{ public Guid SiteID { get; set; } public Guid WidgetID { get; set; } public string NewValue { get; set; } public DateTime updateTime { get; set; } public string GaRefreshToken { get; set; } public string GaAccesToken { get; set; } public string GaAccountName { get; set; } public void getGaValue() { var client = new WebServerClient(GoogleAuthenticationServer.Description, "319907436177.apps.googleusercontent.com", "rIir_V4IWcckC0QoDX3gZLYd"); var auth = new OAuth2Authenticator<WebServerClient>(client, Authenticate); var asv = new AnalyticsService(auth); var request = asv.Data.Ga.Get("ga:" + GaAccountName, "2012-01-01", "2012-02-20", NewValue); request.Dimensions = "ga:pagePath"; request.Sort = "-ga:visitors"; request.MaxResults = 5; var report = request.Fetch(); Console.ReadLine(); NewValue = "http://stackoverflow.com/questions/15644115/TEST"; } private static IAuthorizationState Authenticate(WebServerClient client) { IAuthorizationState state = new AuthorizationState(new string[] { }) { RefreshToken = "REFRESH_TOKEN" }; client.RefreshToken(state); return state; }}\[/code\]but when i try to compile this i get the following error:\[code\]Error 1 The best overloaded method match for 'Google.Apis.Analytics.v3.AnalyticsService.AnalyticsService(Google.Apis.Services.BaseClientService.Initializer)' has some invalid arguments H:\vs12\ManagementAPI\ManagementAPI\Models\Value.cs 27 23 ManagementAPIError 2 Argument 1: cannot convert from 'Google.Apis.Authentication.OAuth2.OAuth2Authenticator<DotNetOpenAuth.OAuth2.WebServerClient>' to 'Google.Apis.Services.BaseClientService.Initializer' H:\vs12\ManagementAPI\ManagementAPI\Models\Value.cs 27 44 ManagementAPI\[/code\]I also tried to "fix" the api dll as described in the other thread, but this would not compile.I would like to post this as a comment on the other answer but since I can't, I try to do this with a new question.EDIT: Used the wrong version, this will still not compile though.
 
Back
Top