Hello,
i try to connect to Google API but i have always the same error.
Do you have an idea?
protected void Page_Load(object sender, EventArgs e)
{
// Register the authenticator.
var provider = new
NativeApplicationClient(GoogleAuthenticationServer.Description)
{
ClientIdentifier = "myclientid",
ClientSecret = "myclientsecret"
};
var auth = new
OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthorization);
// Create the service.
var service = new TasksService(new
BaseClientService.Initializer()
{
Authenticator = auth
});
TaskLists results = service.Tasklists.List().Fetch();
Console.WriteLine("Lists:");
foreach (TaskList list in results.Items)
{
Console.WriteLine("- " + list.Title);
}
Console.ReadKey();
}
private static IAuthorizationState
GetAuthorization(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);
}
--
You received this message because you are subscribed to the Google Groups
"OAuth" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.