MyOwnClone / google-api-dotnet-client

Automatically exported from code.google.com/p/google-api-dotnet-client
Apache License 2.0
1 stars 0 forks source link

Error occurred while sending a direct message or getting the response. #390

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am getting the error "Error occurred while sending a direct message or 
getting the response." while trying to get Google Analytics v3 data.

Steps to recreate the issue:
AuthorizationServerDescription desc = GoogleAuthenticationServer.Description;

                X509Certificate2 keyA = new X509Certificate2(@"C:\Visual Studio Projects\ClientKey\xxx-privatekey.p12", "notasecret", X509KeyStorageFlags.Exportable);
                string scope = Google.Apis.Analytics.v3.AnalyticsService.Scopes.Analytics.ToString().ToLower();

                AssertionFlowClient clientA = new AssertionFlowClient(desc, keyA) { ServiceAccountId = "yyy.apps.googleusercontent.com", Scope = scope };
                OAuth2Authenticator<AssertionFlowClient> auth = new OAuth2Authenticator<AssertionFlowClient>(clientA, AssertionFlowClient.GetState);

                var gas = new AnalyticsService(new BaseClientService.Initializer()
                {
                    Authenticator = auth
                });              

         DataResource.GaResource.GetRequest response = gas.Data.Ga.Get(profileId, startDate, endDate, metrics);
                    response.Dimensions = dimensions;
                    response.MaxResults = 10000;
                    response.StartIndex = iStartIndex;
                    //response.Oauth_token = access_token;
                    GaData report = response.Execute(); //

I get the error of "Error occurred while sending a direct message or getting 
the response." while executing  GaData report = response.Execute();

What version of the product are you using? Google.Apis.Analytics.v3.Data
What is your operating system?  Windows 7
What is your IDE?
What is the .NET framework version? .Net 4.0

Please help!

Original issue reported on code.google.com by k3v1np...@gmail.com on 17 Sep 2013 at 4:14

GoogleCodeExporter commented 9 years ago
Try to change your scopes assignment to:

string scope = 
Google.Apis.Analytics.v3.AnalyticsService.Scopes.Analytics.GetStringValue();

(You may need to add using Google.Apis.Util; also as another using statement in 
the beginning of your file)

See the following link as a good example:
https://code.google.com/p/google-api-dotnet-client/source/browse/Books.ListMyLib
rary/Program.cs?repo=samples#39

Original comment by pele...@google.com on 19 Sep 2013 at 7:27

GoogleCodeExporter commented 9 years ago
I'm closing this issue, feel free to reopen it if you feel like.

By the way take a look in our samples repository, there is a Plus sample that 
use service account:
https://code.google.com/p/google-api-dotnet-client/source/browse/Plus.ServiceAcc
ount/Program.cs?repo=samples

Original comment by pele...@google.com on 19 Sep 2013 at 7:28