Ok, that is partly because i screwed up in making your live easier.

You are assuming that service.SetAuthenticationToken is setting the  
token, regardless what kind of access you are using... And it should.  
I just changed the code to do so in the future.

In your version though, the SetAuthenticationToken only set's the  
client login factories token. So your call below does nothing.

But it should still work, as you are setting the token on the factory  
itself, which is the way of doing it right now.

It looks like you are using the one time token though, not the session  
token ? Or is that i copy/paste error ? You should be using the  
session token for authentication.

Frank Mantek
Google




On Jun 5, 2008, at 7:25 AM, jai wrote:

>
> Hi Frank,
>
> Thanks for interest.
>
> See I first use this line to get a token.
>
> lnkOpenGoogle.NavigateUrl =
> AuthSubUtil.getRequestUrl(Request.Url.ToString(), "http://
> www.google.com/m8/feeds/default", false, true);
>
> It given me one time token that i convert as a session token using
> following code;
>
> token = AuthSubUtil.getTokenFromReply(Request.Url);
> Session["Token"] = AuthSubUtil.exchangeForSessionToken(token, null);
>
> GAuthSubRequestFactory authFactory = new GAuthSubRequestFactory("cp",
> "GmailTest");
> authFactory.Token = token;
>
> ContactService service = new
> ContactService(authFactory.ApplicationName);
> service.RequestFactory = authFactory;
> service.SetAuthenticationToken(authFactory.Token);
>
> After that I create a new entry for my address book by using the
> following code;
>
> ContactEntry contactEntry = new ContactEntry();
> contactEntry.Title.Text = "Testing";
>
> contactEntry.Emails.Clear();
> EMail primaryEmail = new EMail("[EMAIL PROTECTED]");
> primaryEmail.Address = "[EMAIL PROTECTED]";
> primaryEmail.Primary = true;
> primaryEmail.Rel = ContactsRelationships.IsWork;
> contactEntry.Emails.Add(primaryEmail);
>
> EMail secondaryEmail = new EMail("[EMAIL PROTECTED]");
> secondaryEmail.Address = "[EMAIL PROTECTED]";
> secondaryEmail.Rel = ContactsRelationships.IsHome;
> contactEntry.Emails.Add(secondaryEmail);
>
> contactEntry.Phonenumbers.Clear();
> PhoneNumber phoneNumber = new PhoneNumber("9999999999");
> phoneNumber.Primary = true;
> phoneNumber.Rel = ContactsRelationships.IsMobile;
> contactEntry.Phonenumbers.Add(phoneNumber);
>
> contactEntry.PostalAddresses.Clear();
> PostalAddress postalAddress = new PostalAddress();
> postalAddress.Value = "123 somewhere lane";
> postalAddress.Primary = true;
> postalAddress.Rel = ContactsRelationships.IsHome;
> contactEntry.PostalAddresses.Add(postalAddress);
>
> contactEntry.Content.Content = "Testing";
>
>
> Now when I try add the contact using following code it given me error
> "Token invalid - Invalid AuthSub token. (Error 401)"
>
> Uri feedUri = new Uri(ContactsQuery.CreateContactsUri("default"));
> ContactEntry createdContact = (ContactEntry)service.Insert(feedUri,
> contactEntry);
>
>
> My Assemblies are :-
> Google.GData.Client         Version - 1.1.3.23925
> Google.GData.Contacts    Version - 1.1.3.23927
> Google.GData.Extensions Version - 1.1.3.23925
>
>
> Thanks
> Jai
>
>
> On Jun 4, 7:38 pm, Frank Mantek <[EMAIL PROTECTED]> wrote:
>> ok, so how did you get the token in the Session object?
>>
>> Frank Mantek
>> Google
>> On Jun 4, 2008, at 3:52 PM, jai wrote:
>>
>>
>>
>>> It say Invalid Token Error 401.
>>
>>> Thanks for your reply.
>>
>>> On Jun 4, 6:03 pm, Frank Mantek <[EMAIL PROTECTED]> wrote:
>>>> It would help to know if there are more details in the exception
>>>> (check the response property). If i would have to guess it's  
>>>> probably
>>>> because the base projection (which is created by the
>>>> createcontactsuri
>>>> method below) is deprecated...
>>
>>>> So try creating the Uri by hand (i am changing the .NET client as  
>>>> we
>>>> speak, that method will by default create a full projection in the
>>>> future).
>>
>>>> Frank Mantek
>>>> Google
>>>> On Jun 4, 2008, at 2:37 PM, jai wrote:
>>
>>>>> Hi,
>>
>>>>> Did you get any solution for the same problem.
>>
>>>>> Kindly let me know if you find any solution.
>>
>>>>> Thanks in advance,
>>
>>>>> Jai
>>
>>>>> On Apr 26, 5:03 pm, Deeraf <[EMAIL PROTECTED]> wrote:
>>>>>> This exception is occured when i try to run the following code
>>>>>> Execution of request 
>>>>>> failed:http://www.google.com/m8/feeds/contacts/default/base
>>
>>>>>> GAuthSubRequestFactory authFactory = new
>>>>>> GAuthSubRequestFactory("cp","GmailTest");
>>>>>>          authFactory.Token = (String)Session["token"];
>>>>>>          ContactService service = new
>>>>>> ContactService(authFactory.ApplicationName);
>>>>>>          service.RequestFactory = authFactory;
>>
>>>>>>          ContactEntry newEntry = new ContactEntry();
>>>>>>          newEntry.Title.Text = "Information";
>>
>>>>>>          EMail primaryEmail = new EMail("[EMAIL PROTECTED]");
>>>>>>          primaryEmail.Primary = true;
>>>>>>          primaryEmail.Rel = ContactsRelationships.IsWork;
>>>>>>          newEntry.Emails.Add(primaryEmail);
>>
>>>>>>          PhoneNumber phoneNumber = new  
>>>>>> PhoneNumber("111-111-222");
>>>>>>          phoneNumber.Primary = true;
>>>>>>          phoneNumber.Rel = ContactsRelationships.IsMobile;
>>>>>>          newEntry.Phonenumbers.Add(phoneNumber);
>>
>>>>>>          newEntry.Content.Content = "Information Center";
>>
>>>>>>          Uri uriFeed = new
>>>>>> Uri(ContactsQuery.CreateContactsUri("default"));
>>>>>>          ContactEntry createEntry =
>>>>>> (ContactEntry)service.Insert(uriFeed, newEntry);
>>
>>>>>> Last line is having exception
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Data Protocol" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to