Issue 717 in google-gdata: Importing gmail contacs using Oauth2

19 views
Skip to first unread message

google...@googlecode.com

unread,
May 30, 2015, 2:17:13 AM5/30/15
to gdata-dotnet-...@googlegroups.com
Status: New
Owner: ----

New issue 717 by sangeeth...@gmail.com: Importing gmail contacs using Oauth2
https://code.google.com/p/google-gdata/issues/detail?id=717

Please FInd the below Code .. m getting exception" Execution of
authentication request returned unexpected result: 404 "
please help me to fix it

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Google.GData.Extensions.Apps;
using Google.GData.Client;
using Google.Contacts;
public partial class _Default : System.Web.UI.Page
{
private static string clientId;
private static string clientSecret;
private static string domain;

private static string applicationName = "Test-OAuth2";

// Installed (non-web) application
private static string redirectUri
= "http://localhost:51598/WebSite1/Default2.aspx" ;

// Requesting access to Contacts API and Groups Provisioning API
private static string scopes = "https://www.google.com/m8/feeds/";

protected void Page_Load(object sender, EventArgs e)
{
clientId
= "51382749591-acdara9kbhlrvo529ivnhbigsvd0m0rb.apps.googleusercontent.com";
clientSecret = "IZGxIUoGpGjBqYFqDpNabicv";
domain = "";

OAuth2Parameters parameters = new OAuth2Parameters()
{
ClientId = clientId,
ClientSecret = clientSecret,
RedirectUri = redirectUri,
Scope = scopes
};

string url = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
Console.WriteLine("Authorize URI: " + url);
parameters.AccessCode = Console.ReadLine();

OAuthUtil.GetAccessToken(parameters);

// Testing OAuth 2.0 with a Request-based library
RunContactsSample(parameters);


}
private static void RunContactsSample(OAuth2Parameters parameters)
{
try
{
RequestSettings settings = new RequestSettings(applicationName,
parameters);
ContactsRequest cr = new ContactsRequest(settings);

Feed<Contact> f = cr.GetContacts();
foreach (Contact c in f.Entries)
{
Console.WriteLine(c.Name.FullName);
}
}
catch (Exception a)
{
Console.WriteLine("A Google Apps error occurred.");
Console.WriteLine();
//Console.WriteLine("Error code: {0}", a.ErrorCode);
//Console.WriteLine("Invalid input: {0}", a.InvalidInput);
//Console.WriteLine("Reason: {0}", a.Reason);
}
}
}





--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages