Hello, If your application needs the user to authorize the requests sent to the API (which is the case of Google Contacts API), please use OAuth<http://code.google.com/apis/gdata/docs/auth/oauth.html>instead of ClientLogin as it lets users grant access without having to give away their login & password.
For installed applications, there are 2 choices: * Have the application listen on a port for a redirect from our authorization server: once the user grants access, our server redirects the user to the provided redirect URI which can be localhost. * Ask the authorization to provide a code that the user can copy & paste into your application. An OAuth token is usually long lived and should work until the users decide to revoke access in their issued tokens console. The best way to check if the token works is to surround all your API calls with try/catch blocks and check for HTTP 403 status code as a token can be revoked at any time. Best, Alain On Sat, Oct 8, 2011 at 2:58 PM, HK1 <[email protected]> wrote: > Late last night I finally pieced something together that works > (working code posted below). However, I still have many unanswered > questions. Here's a few of them. > > 1) How do I retrieve the login message or the capcha during a login > failure? > > 2) How can I save and reuse the token. How long with the token last? > Is there some way I can check to see if I'm logged in or not. I admit > the whole login thing has me fairly confused. > > 3) How can I retrieve an error message in the event that inserting the > contact fails? > > > > Dim conserv As New ContactsService("MyCompany-MyApp-v1.0") > Dim authFactory As New GDataGAuthRequestFactory("cp", > "MyCompany-MyApp-v1.0") > authFactory.AccountType = "GOOGLE" > > conserv.RequestFactory = authFactory > conserv.setUserCredentials("[email protected]", > "YourPassword") > conserv.QueryClientLoginToken() > > Dim nc As New ContactEntry > > With nc > .Name = New Google.GData.Extensions.Name() > .Name.FullName = "John Davis" > .Name.GivenName = "John" > .Name.FamilyName = "Davis" > End With > > Dim org As New Google.GData.Extensions.Organization() > With org > .Rel = > Google.GData.Extensions.ContactsRelationships.IsWork > .Name = "Garfield" > .Primary = True > End With > > nc.Organizations.Add(org) > > Dim ph As New > Google.GData.Extensions.PhoneNumber("111-222-3333") > With ph > .Primary = True > .Rel = > Google.GData.Extensions.ContactsRelationships.IsWork > 'I'm not sure when you need to use this > '.Uri = "tel:+1111222333" > End With > nc.Phonenumbers.Add(ph) > > Dim urifeed As New > Uri(ContactsQuery.CreateContactsUri("default")) > conserv.Insert(urifeed, nc) > > -- > You received this message because you are subscribed to the Google > Groups "Google Contacts, Shared Contacts and User Profiles APIs" 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://code.google.com/apis/contacts/community/forum.html > -- Alain Vongsouvanh | Developer Programs Engineer -- You received this message because you are subscribed to the Google Groups "Google Contacts, Shared Contacts and User Profiles APIs" 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://code.google.com/apis/contacts/community/forum.html
