cdanielm58 / google-api-dotnet-client

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

Bad Request in DotNetOpenAuth #365

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I got BadReQuestError (ProtocolException) in DataResource.Execute() . I have 
all the keys. Fetch() gives error (Method not found) in assembly.
Can u please give some help about this .

            string scope = Google.Apis.Analytics.v3.AnalyticsService.Scopes.Analytics.ToString();
            string scope_url = "https://www.googleapis.com/auth/" + scope;

            //client_id: This is the "Email Address" one, not the "Client ID" one... oddly...
            string client_id = "nnnnnnnnnnnnnnnnnnnnnnnnnn.apps.googleusercontent.com";

            //key_file: This is the physical path to the key file you downloaded when you created your Service Account
            string key_file = @"F:\GoogleAnalyticDLL\nnnnnnnnnnnnnnnnnnnnnnn-privatekey.p12";

            //key_pass: This is probably the password for all key files, but if you're given a different one, use that.
            string key_pass = "notasecret";

            try
            {
                AuthorizationServerDescription desc = GoogleAuthenticationServer.Description;

                //key: Load up and decrypt the key
                X509Certificate2 key = new X509Certificate2(key_file, key_pass, X509KeyStorageFlags.Exportable);

                //client: we're using the AssertionFlowClient, because we're logging in with our certificate
                AssertionFlowClient client = new AssertionFlowClient(desc, key) { ServiceAccountId = client_id, Scope = scope_url };
                OAuth2Authenticator<AssertionFlowClient> auth = new OAuth2Authenticator<AssertionFlowClient>(client, AssertionFlowClient.GetState);

                //gas: An instance of the AnalyticsService we can query
                AnalyticsService gas = new AnalyticsService(new BaseClientService.Initializer() { Authenticator = auth });

                //r: Creating our query
                DataResource.GaResource.GetRequest r = gas.Data.Ga.Get("ga:38996922", "2012-07-01", "2012-07-31", "ga:visitors");

                //d: Execute and fetch the results of our query
                GaData d = r.Execute();

                //At this point, d should contain the number of visitors you got between "2012-09-26" and "2012-10-10"
                //Do with it what you will.
            }
            catch(Exception ex)
            {
                throw ex;
            }

Original issue reported on code.google.com by viv...@interfaceinfosoft.com on 5 Aug 2013 at 9:22

GoogleCodeExporter commented 9 years ago
Can you please send the stack trace?
Which method not found? in which assembly?

Original comment by pele...@google.com on 6 Aug 2013 at 3:49

GoogleCodeExporter commented 9 years ago
HI,

found some solution to this error?

Original comment by saft...@gmail.com on 20 Aug 2013 at 12:54

GoogleCodeExporter commented 9 years ago
Yes I got the solution .

Original comment by viv...@interfaceinfosoft.com on 20 Aug 2013 at 6:56

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 4 Sep 2013 at 8:30

GoogleCodeExporter commented 9 years ago
Consider using our new Auth library 
(http://www.nuget.org/packages/Google.Apis.Auth/).
Use the information in our OAuth2 page in this site and also take a look in our 
samples for working solutions.

I'm closing this issue, because we are not going to support DotNetOpenAuth 
anymore.
I'm closing this issue, but feel free to reopen it if you think so.
Thanks!

Original comment by pele...@google.com on 24 Oct 2013 at 1:49