title: Code trying to find ServiceAccountCredential.cs file while accessing Google Analytics using OAUTH 2.0
body: <p>I am trying to access Google Analytics data for <code>ga:visits</code> and <code>ga:transactions</code> using OAUTH 2.0 authentication. I have followed the following steps :  </p>
  
  <ol>
  <li>Enabled the Google Analytics API on the <a href="https://code.google.com/apis/console/" rel="nofollow">https://code.google.com/apis/console/</a> website.Also, created a client ID and saved the .p12 key  </li>
  <li>The generated email id was provided Read and Analyze access on Analytics website.  </li>
  <li>I have created a Windows form application and also downloaded the NuGet package using the package command:- Install-Package Google.Apis.Analytics.v3
  All the references including Google.Apis,Google.Apis.Analytics.v3,Google.Apis.Auth,Google.Apis.Auth.PlatformServices,Google.Apis.Core,Google.Apis.PlatformServices are added into the project  </li>
  </ol>
  
  <p>Further, while accessing the data am facing an error :- </p>
  
  <blockquote>
    <p>Locating source for
    <code>c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Auth.DotNet4\OAuth2\ServiceAccountCredential.cs</code></p>
  </blockquote>
  
  <p>while the following line of code is run :   </p>
  
  <pre><code>var credential = new ServiceAccountCredential(new     ServiceAccountCredential.Initializer(serviceAccountEmail)         
   {    
      Scopes = new[] { AnalyticsService.Scope.AnalyticsReadonly }    
   }.FromCertificate(cert));   
  </code></pre>
  
  <p>Could you please help me with this error.
  Please find below the code used :-   </p>
  
  <pre><code>using System;  
  using System.Collections.Generic;  
  using System.ComponentModel;  
  using System.Data;  
  using System.Drawing;  
  using System.Linq;  
  using System.Text;  
  using System.Threading.Tasks;  
  using System.Windows.Forms;  
  using Google.Apis.Analytics.v3;  
  using System.Security.Cryptography.X509Certificates;  
  using Google.Apis.Auth.OAuth2;  
  using Google.Apis.Services;  
  
  namespace WindowsFormsApplication5  
  {  
      public partial class Form1 : Form  
      {  
          public Form1()  
          {  
              InitializeComponent();  
          }  
  
          private void Form1_Load(object sender, EventArgs e)
          {
  
              string keyFilePath = "C:\\Fetch GA Data-348e7435108b.p12";
              string serviceAccountEmail= "xx@developer.gserviceaccount.com";     
              string keyPassword = "notasecret";
              string websiteCode = "8482xxxx";     
              AnalyticsService service = null; 
  
              //loading the Key file     
              var certificate = new X509Certificate2(keyFilePath, keyPassword, X509KeyStorageFlags.Exportable);  
  
              //Add Scopes
              var scopes =     
              new string[] { AnalyticsService.Scope.Analytics,AnalyticsService.Scope.AnalyticsEdit,AnalyticsService.Scope.AnalyticsManageUsers,AnalyticsService.Scope.AnalyticsReadonly   
  };       
  
              //create a new ServiceAccountCredential 
              var credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)     
              {
                  //Scopes = scopes     
                  Scopes = new[] { AnalyticsService.Scope.AnalyticsReadonly }
  
              }.FromCertificate(cert));    
  
              //Create a Service
              service = new AnalyticsService(new BaseClientService.Initializer()    
              {    
                  HttpClientInitializer = credential    
              }); 
  
  
              DataResource.GaResource.GetRequest request = service.Data.Ga.Get(     
                "ga:" + websiteCode, "2015-05-27", "2015-05-27","ga:visits");     
              request.Dimensions = "ga:year,ga:month,ga:day";     
              var data = request.Execute();   
  
              }
  
  
          }
  }
  </code></pre>