TAdvGCalendar Start & Stop

Using extracts from the Demo, I have AdvGCal working. However, I want to run as a Service so I want to:

1) Temporarily STOP the connection,

2) Restart STOPped connection,

3) Be informed, or be able to test if the connection has been CLOSED because of an inactivity timeout.

Can anyone please suggest how these can be done without DESTROYing the TAdvGCalendar object and re-CREATing it?

Thanks, Martin

Hi, 


Have you tried using the LoadTokens (to retrieve an existing token if available) and TestTokens (to test if the token is still valid) calls?

Examples can be found in the demos included with the product.

I do indeed use "LoadTokens" as described in the demo.

I'm not sure if "TestTokens" is what I want.



I kept the GCalendarDemo running for several hours and after 3 hours it did not respond, the log showing "GET RESULT:{"error": {"errors":[{"domain": "global","reason": "authError","message": "Invalid Credentials"...".

How do I detect that in my program and is I need to do is re-issue "LoadTokens"?



Is that what "TestTokens" is for?

But I don't really want to use "TestTokens" before every request, I'd rather be told that I need to issue "LoadTokens" again.

Thanks, Martin

Yes TestTokens is a test to know if the currently loaded tokens are still valid.
If TestTokens returns false, calling LoadTokens again will not help to re-enable authentication as it means the current tokens are expired. 
If tokens are expired for Google Calendar, you can call RefreshAccess to refresh the access token.

"TestTokens: Boolean: performs a test if the access token is still accepted". I don't think that this IS what I want. I have been using the same saved tokens for a week or 2 now without problem.

What I'm talking about is a TIMEOUT which happens after a period (not sure how long) of inactivity.

There seems to be a general lacking of error pass-back when a request doesn't work.

How can my program be told that an AdvGCalender request failed, and find details of the failure?



The other problem with using "RefreshAccess" is that my program is running as a service on a server that doesn't have much human interaction, issuing "RefreshAccess" would not be helpful.

Are you referring to a timeout on (HTTP) calls itself (due to network failure for example)?

In such case, the function calls should return false or an error code.

If there is an issue with the lifetime of the access tokens, RefreshAccess is the call that needs to be used to extend the lifetime.


No, I'm talking about an inactivity timeout (something around 2-3 hours or so).

If I'm informed that a message has been rejected because of the timeout then I can re-issue the DoAuth to re-authorise the connection and then re-issue the original request.

If there is a chance for a longer inactivity timeout, you could proactively do a RefreshAccess before starting a new operation.

Ok, I was confused over what "RefreshAccess" actually meant. I have tried it and it works fine. Looking at the log, I get ""expires_in" : 3600" back, suggesting that the timeout is 1 hour. I'll therefore refresh after a 50 minute period when I next need GCal activity.

Thank you for your help, we got there in the end.