0

I am trying to build a C# application that queries my google contacts,and prints them to console.

The email address is :bhmi12@gmail.com excellent is the name of the google app.

I have two problems:

The First Problem every time i run the app i have to call:

string url = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);

surf to the URL and get a new AccessCode even that google claims u only have to do it once. and then u get an access token.

The second Problem is that this code doesnt work, when it goes to PrintAllContacts it failes under a wierd exception:

There is some error in your request thats all we know"(the google response 
to my request).

Is this the right way to write the scope? thanks very much. The code:

{
            OAuth2Parameters parameters = new OAuth2Parameters();    
            parameters.ClientId = @"my id";
            parameters.ClientSecret = @"my secret";
            parameters.RedirectUri = @"urn:ietf:wg:oauth:2.0:oob";
            parameters.ResponseType="code";
            parameters.Scope = @"https://www.google.com/m8/feeds/contacts/bhmi12%40gmail.com/full";

            //string url = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
            parameters.AccessCode = @"";
            try
            {
                OAuthUtil.GetAccessToken(parameters);
                //OAuthUtil.RefreshAccessToken(parameters);
                var contacts = new ContactsRequest(new RequestSettings("excellent", parameters));
                PrintAllContacts(contacts);
            }
            catch (GDataRequestException e)
            {
                Console.WriteLine("Operation failed ({0}): {1}", e.Message, e.ResponseString);
            }
}
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
TheYellowKing
  • 115
  • 1
  • 1
  • 9

1 Answers1

0

No. The scope is the following constant string value that looks like a URL: "https://www.googleapis.com/auth/contacts.readonly"

If you intend to modify the user's contacts, then use this instead: "https://www.google.com/m8/feeds"

Reference: https://developers.google.com/google-apps/contacts/v3/#authorizing_requests_with_oauth_20

Blake O'Hare
  • 1,863
  • 12
  • 16