sanvlr12 / google-api-dotnet-client

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

OAuth2Authenticator expects <TClient> but on the sample, not strongly type was used. #121

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Error   1   Using the generic type 
'Google.Apis.Authentication.OAuth2.OAuth2Authenticator<TClient>' is occuring on 
compile time because of the line below.

AuthenticatorFactory.GetInstance().RegisterAuthenticator(() => new 
OAuth2Authenticator(provider, GetAuthentication));

I thought OAuth2Authenticator class uses strongly type object

Original issue reported on code.google.com by kulashak...@gmail.com on 11 Aug 2011 at 9:00

GoogleCodeExporter commented 9 years ago
Which sample does use this syntax? Can you show me the URL? The 
AuthenticatorFactory has also been removed in one of the latest changes; the 
service constructor now takes the Authenticator.

Original comment by mlin...@google.com on 11 Aug 2011 at 3:04

GoogleCodeExporter commented 9 years ago
The problem I'm encountering is in red highlights. One thing I'm sure about
this is I downloaded the outdated library, but that's what on the download
link. If you could provide or send a link of the latest version of dlls it
would be better.

Here is the link --> http://code.google.com/apis/tasks/v1/using.html

using System;
using System.Diagnostics;
using DotNetOpenAuth.OAuth2;
using Google.Apis.Authentication;
using Google.Apis.Authentication.OAuth2;
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
using Google.Apis.Tasks.v1;
using Google.Apis.Tasks.v1.Data;
using Google.Apis.Util;

...

  public static void Main(string[] args)
  {
      // Register the authenticator. The Client ID and secret have to be
copied from the API Access
      // tab on the Google APIs Console.
      var provider = new NativeApplicationClient(GoogleAuthenticationServer.
Description);
      provider.ClientIdentifier = "YOUR_CLIENT_ID";
      provider.ClientSecret = "YOUR_CLIENT_SECRET";
      *AuthenticatorFactory.GetInstance().RegisterAuthenticator(() => new
OAuth2Authenticator(provider, GetAuthentication));*

      // Create the service. This will automatically call the previously
registered authenticator.
      var service = new TasksService();

      ...
  }

  private static IAuthorizationState GetAuthentication(
NativeApplicationClient arg)
  {
      // Get the auth URL:
      IAuthorizationState state = new AuthorizationState(new[] {
TasksService.Scopes.Tasks.GetStringValue() });
      state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl
);
      Uri authUri = arg.RequestUserAuthorization(state);

      // Request authorization from the user (by opening a browser window):
      Process.Start(authUri.ToString());
      Console.Write("  Authorization Code: ");
      string authCode = Console.ReadLine();
      Console.WriteLine();

      // Retrieve the access token by using the authorization code:
      return arg.ProcessUserAuthorization(authCode, state);
  }

Original comment by kulashak...@gmail.com on 11 Aug 2011 at 7:30

GoogleCodeExporter commented 9 years ago
Thanks for pointing out that issue. The documentation there is indeed 
out-dated. For the moment you can stick with the samples which can be found at:

http://code.google.com/p/google-api-dotnet-client/wiki/APILibraries#Tasks_API

Original comment by mlin...@google.com on 11 Aug 2011 at 7:52

GoogleCodeExporter commented 9 years ago
Thanks for your respond as I am waiting for it. I have a question, I'm
planning to use REST instead of the library. I will use it using
HttpWebRequest what I wanna know is do you have samples for this? I'm hoping
that you can provide one.

On Thu, Aug 11, 2011 at 12:53 PM,
<google-api-dotnet-client@googlecode.com>wrote:

Original comment by kulashak...@gmail.com on 11 Aug 2011 at 7:58

GoogleCodeExporter commented 9 years ago
The links you mentioned doesn't have the dlls, only links

On Thu, Aug 11, 2011 at 12:57 PM, Christopher R. Valencia <
kulashaker30@gmail.com> wrote:

Original comment by kulashak...@gmail.com on 11 Aug 2011 at 8:22

GoogleCodeExporter commented 9 years ago
Sorry, try again. The links should work now.

Original comment by mlin...@google.com on 11 Aug 2011 at 10:01

GoogleCodeExporter commented 9 years ago

Original comment by mlin...@google.com on 12 Aug 2011 at 12:54

GoogleCodeExporter commented 9 years ago
Can you show me the working .dlls required the sample here -> *
http://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.CreateTask
s/Program.cs?repo=samples
*

I already reference all the dlls from Binary folder and still can't find the
namespace --> (Google.Apis.Samples.Helper)

Original comment by kulashak...@gmail.com on 14 Aug 2011 at 3:15

GoogleCodeExporter commented 9 years ago
The Google.Apis.Samples.Helper is a project in the Sample solution:
 http://code.google.com/p/google-api-dotnet-client/source/browse/?repo=samples#hg%2FSampleHelper

I would recommend downloading the entire Sample solution as a .zip, and 
continuing from there:
 http://contrib.google-api-dotnet-client.googlecode.com/hg/Current/Generated/ZipFiles/Samples.zip 

Original comment by mlin...@google.com on 15 Aug 2011 at 1:13

GoogleCodeExporter commented 9 years ago

Original comment by mlin...@google.com on 17 Aug 2011 at 8:25

GoogleCodeExporter commented 9 years ago
 AuthenticatorFactory.GetInstance().RegisterAuthenticator(
              () => new OAuth2Authenticator(provider, GetAuthentication));

change this to

   AuthenticatorFactory.GetInstance().RegisterAuthenticator(
              () => new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthentication));

Original comment by afzalsha...@gmail.com on 8 Jul 2012 at 11:03

GoogleCodeExporter commented 9 years ago
yeah...this still doesn't work. You guys test this stuff before you post it or 
what? It never calls the "GetAuthentication" method at all and therefore cannot 
post. All i get is "login required" everytime I run this.

Original comment by tyler_wa...@jabil.com on 9 Aug 2012 at 8:14

GoogleCodeExporter commented 9 years ago
yeah...this still doesn't work. You guys test this stuff before you post it or 
what? It never calls the "GetAuthentication" method at all and therefore cannot 
post. All i get is "login required" everytime I run this.

did they fix it?

Original comment by pepe1...@gmail.com on 8 Feb 2013 at 12:57

GoogleCodeExporter commented 9 years ago
Yeah. The GetAuthentication method never gets called for me too.

Original comment by pradee...@gmail.com on 4 Mar 2013 at 12:53

GoogleCodeExporter commented 9 years ago
Trying to find the replacement code for the following lines:

            AuthenticatorFactory.GetInstance().RegisterAuthenticator(
                    () => new OAuth2Authenticator(provider, GetAuthentication));

and

            IAuthorizationState state = new AuthorizationState(new[] { CalendarService.Scopes.Calendar.GetStringValue() });

AuthenticatorFactor seems to be obsolete.  

Original comment by ImStanVi...@gmail.com on 18 Jun 2013 at 4:39