10
Views
6
Comments
Problem with timer and Google Drive Connector
Question

Hello,I have a server action that write on a google drive account with GDriveConnectorReactive. It works very well. But when I want to this server action with a timer, I have this error :

Environment Information

eSpaceVer: Id=1814, PubId=0, CompiledWith=11.10.7.060000

RequestUrl: http://ecbeao048.outsystemscloud.com/ParceLVA/_TimerHandler.asmx (Method: POST)

AppDomain: /LM/W3SVC/51/ROOT/ParceLVA-89-132512146371963632

FilePath: C:\OutSystems\Sandboxes\ECBEAO048\Platform Server\running\ParceLVA\

ClientIp: 127.0.0.1

Locale: en-US

DateFormat: yyyy-MM-dd

PID: 13204 ('w3wp', Started='11/27/2020 6:46:14 PM', Priv=795Mb, Virt=2116301Mb)

TID: 376

Thread Name:

.NET: 4.0.30319.42000

Stack

ssGDriveConnectorReactive.ExcptNoAccessTokenException: NoAccessTokenException

   at ssGDriveConnectorReactive.CcGoogleapis.ActionFileCreate(HeContext heContext, ICcGoogleapisCallbacks _callbacks, String inParamOcrLanguage, Boolean inParamKeepRevisionForever, Boolean inParamIgnoreDefaultVisibility, String inParamContentType, Byte[] inParamRequest, STFile2Structure& outParamOutFile)

   at ssGDriveConnectorReactive.Actions.ActionFiles_Create(HeContext heContext, String inParamName, String inParamDescription, String inParamMimeType, String inParamParentId, String inParamOcrLanguage, Boolean inParamKeepRevisionForever, Boolean inParamIgnoreDefaultVisibility, Byte[] inParamFileContent, STFileStructure& outParamInsertedFile)

   at ssParceLVA.RsseSpaceGDriveConnectorReactive.MssFiles_Create(HeContext heContext, String inParamName, String inParamDescription, String inParamMimeType, String inParamParentId, String inParamOcrLanguage, Boolean inParamKeepRevisionForever, Boolean inParamIgnoreDefaultVisibility, Byte[] inParamFileContent, IRecord& outParamInsertedFile)

   at ssParceLVA.Actions.ActionBackup_Data_ParceLVA(HeContext heContext)

   at ssParceLVA.TimerBackup_Data_ParceLVA.Execute(HeContext heContext, Int32 timeout)

   

I don't know what's the problem. When we use timer, is there something else to declare in console.developers.google.com?

Thank you in advance

Rank: #369

Hi Malguy,

I don't know the details, but do you realize that when you run a timer, there's no active user in the session?
If you for example look up user credentials or an Access Token based on the logged in user's Id, that this can cause your current error.

Regards,
Lennart

Rank: #55098

Hello Lennart,

Thank you for your answer. My server action create an Excel file from sql in database entity and save in on a google drive account.  Did I need a active user for it?

Rank: #369

I've looked into the Reactive variant of the Google Drive Connector, since i hadn't used that one before.
What I noticed is that indeed the current UserId is being used to get the Google Drive Token (In aggregate GetGoogleDriveToken in actionGetGDriveToken in Utilities. It uses GetUserId() to get the token. In Timers this action returns a NullIdentifier(), since there's no user.



Rank: #55098

Thank you for the details. So there's no solution for my problem. 

Is there any other option to save a database entity daily, to get a backup of data?

Rank: #369

Of course there's a solution, although this might involve some custom action . I just pointed out why your Google Cloud Connector failed when being used from a timer.

One possible solution is to make sure that the configuration is also stored without a UserId in a GoogleDriveToken record. That way it can also be fetched in a timer. Because I don't know anything about your application, I cannot tell you what your best solution is.

Rank: #369

Hi Malguy,

Did you manage to come up with a solution?
I tried to recreate your situation, using the Google Drive Connector Reactive component from a timer action, but I couldn't implement a solution without changing the component itself. Mainly the Utilities actions that need to be public.

I also think that although the component is a reactive application, since it only uses server actions, I don't see a real advantage in using this one instead of the original Google Drive Connector.

Regards,
Lennart