oAuth2 worker object weirdness
Joe Maus
jmaus at theccgllc.com
Mon Aug 12 14:10:09 UTC 2024
Hi,
Just a quick follow up, it seems I cannot get the oAuth2 subclassed worker object to assign to my HTTP object, even though I can call methods in the subclassed object I created, but my subclassed HTTP object works just fine. That said, by using:
Do iorOAUTH2.$callbackinst.$assign($cinst)
and adding the appropriate methods (e.g. $completed, $tokensrefreshed) in my object that contains the code that does the emailing (and has references to oAuth worker object and oHttp subclassed worker object) I was able to get everything to work as expected. $tokensrefreshed() is called now when the token is refreshed by the oAuth worker and I save the token successfully.
I was following the example library's sample code which has its own $callbackinst method, i.e.:
Do iSmtp.$setCallingInst($cinst)
Which was the cause of some of my confusion in how to implement the call back to the parent object as I was trying to fit that into the current worker API and was only being partially successful. So, thank you Phil for pointing out the $callbackinst property which, in my opinion, needs amplification in the on-line docs and the example libraries refactored to use it instead of the current method $setCallingInst.
Kind regards,
Joe Maus
> On Aug 6, 2024, at 8:19 PM, Doug Easterbrook via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
>
> Hi joe.
>
> Just to check some assumptions. … I assume oAuthWorker
>
> is defined in your library classes as an ‘object
> it inherits from $extobjects.OW3.$objects.OAUTH2Worker, so that the $superclass looks like '.OW3.OW3 Worker Objects\OAUTH2Worker’
>
> and when in instantiate it using
>
> Do $objects.oAuthWorker.$newref() Returns iorOAUTH2
>
> I would put in a temporary method in your oAuthWorker object such as $initialize
>
>
>
> and then try getting to if by referring to
>
> do iorOAUTH2.$initialize
>
>
>
> If you can step into that method and then see all the properties and methods, it should work
>
>
>
>
> We do that for HTTP, FTP, iMap, SMTP, Pop3 and crypto workers
>
>
>
> Doug Easterbrook
> Arts Management Systems Ltd.
> mailto:doug at artsman.com
> http://www.artsman.com
> Phone (403) 650-1978
>
>> On Aug 6, 2024, at 4:05 PM, Joe Maus <jmaus at theccgllc.com> wrote:
>>
>> Hi,
>>
>> Omnis 10.22 31896
>>
>> So, I created an oAuthWorker object subclassed from the oAUTH2Worker so I could add some token handling code to deal with the change in the Access token (overriding $tokensrefreshed to save the new data) and it won't work with my oHttpWorker object that is subclassed from the OW3 HTTP worker.
>>
>> If I do this:
>>
>> Do $extobjects.OW3.$objects.OAUTH2Worker.$newref() Returns iorOAUTH2
>>
>> Then most everything works - I can assign the object reference to the http.$oauth2 method and the https object will happily send my email. But I can't save the new oauth details when the tokens are refreshed. If I use the subclassed object, by running this:
>>
>> Do $objects.oAuthWorker.$newref() Returns iorOAUTH2
>>
>> I get everything in it like is seen in the reference created from the base OW3 object, that is, the token is there along with all of the other bits of data and properties and it even allows the code to call my $completed method in the HTTP object ref derived from the subclassed OW3 HTTP object, but the assignment to http.oauth2 fails. I just get a flag false back from the assignment:
>>
>> Do iorHttp.$oauth2.$assign(iorOAUTH2) Returns lOk
>>
>> Anyone have any idea why this assignment would fail or how I might get more information on why the assignment failed? The $completed method does confirm it is not set with this error: "Request is missing required authentication credential."
>>
>> Kind regards,
>>
>> Joe Maus
>> jmaus at theccgllc.com
>> 303-349-6696
>>
>>
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en
mailing list