OAUTH2worker

External objects

Properties Methods 

Properties

$accesstokenThe access token to be used with HTTP, IMAP, POP3 and SMTP connections
$accesstokenexpiryThe expiry date and time of the access token (in UTC time). #NULL means no access expiry date and time is available
$addclientdetailstotokenrequestIf true,the client ID and client secret are added to the body of the token request; if false, they are omitted. Defaults to true
$authorizeurlThe URL of the OAUTH2 authorization endpoint
$callbackinstThe instance to which the worker object sends messages,for example when its processing has completed or has been cancelled.If you do not assign an instance to $callbackinst the worker object sends messages to itself
$clientidThe client id used in conjunction with the client secret to identify the application to the OAUTH2 authorization server
$clientsecretThe client secret used in conjunction with the client id to identify the application to the OAUTH2 authorization server
$errorcodeError code associated with the last action (zero means no error)
$errortextError text associated with the last action (empty means no error)
$followredirectsIf true,the HTTP request will follow a server redirect in order to complete the request
$granttypeA kOW3OAUTH2grant... constant (default kOW3OAUTH2grantAuthorizationCode) setting the grant type used by $authorize().
kOW3OAUTH2grantAuthorizationCode kOW3OAUTH2grantClientCredentials kOW3OAUTH2grantPassword
$oauth2stateA value included in the request that is also returned in the token response
$passwordPassword used in password grant types.
$protocollogIf non-zero,the worker adds a log of protocol activity as a column named log to its wResults row.Defaults to kOW3logNone.Otherwise,a sum of kOW3log... constants
$proxyauthpasswordThe password used to authenticate the user when connecting to $proxyserver using $proxyauthtype
$proxyauthtypeThe type of HTTP authentication to use when connecting to $proxyserver.A kOW3httpAuthType... constant
kOW3httpAuthTypeBasic kOW3httpAuthTypeDigest kOW3httpAuthTypeNone
$proxyauthusernameThe user name used to authenticate the user when connecting to $proxyserver using $proxyauthtype
$proxyserverThe URI of the proxy server to use for all requests from this object e.g. http://www.myproxy.com:8080.Defaults to empty (no proxy server)
$proxytunnelIf true,and $proxyserver is not empty,requests are tunnelled through the HTTP proxy
$redirecturiserveraddressIf not empty (the default value),this property overrides localhost in the redirect URI server address,replacing localhost with the value of this property
$refreshtokenThe refresh token to be used to request a new access token after the access token has expired
$scopeA string identifying the type of access required
$stateA kWorkerState... constant that indicates the current state of the worker object
kWorkerStateCancelled kWorkerStateClear kWorkerStateComplete kWorkerStateInit kWorkerStateRunning
$threadcountThe number of active background threads for all instances of this type of worker object
$timeoutThe timeout (in seconds) for requests.Zero means requests do not time out.For the OAUTH2Worker defaults to 60 with a minimum value of 10;otherwise,defaults to 10 with a minimum value of zero
$tokentypeA string to use as fallback token type if OAuth2 does not return token_type in its response
$tokenurlThe URL of the OAUTH2 token endpoint
$usernameUsername used in password grant types.

Methods

$authorize$authorize([iAuthFlow=kOW3OAUTH2authFlowCodeWithPKCE]) Starts OAUTH2 authorization with $granttype on a background thread.Returns true if thread was successfully started.Properties cannot be assigned while $authorize() is running
$cancel$cancel() If required,cancels execution of worker on background thread.Will not return until the request has been cancelled
$cancelled$cancelled() Method called when the request has been cancelled
$completed$completed(wResults) Method called when the request completes.wResults is a row containing the results of executing the request
$getsecureoptions$getsecureoptions([&bVerifyPeer,&bVerifyHost,&cCertFile,&cPrivKeyFile,&cPrivKeyPassword]) gets the options that affect how secure connections are established (the options do not apply to SFTP)
$load$load(xOAUTH2[,xKey]) Loads properties ($clientid,$clientsecret,$authorizeurl,$tokenurl,$scope,$accesstoken,$refreshtoken,$accesstokenexpiry) from encrypted buffer xOAUTH2.xKey is a 256 bit AES encryption key.Returns true if successful
$save$save(&xOAUTH2[,xKey]) Saves properties ($clientid,$clientsecret,$authorizeurl,$tokenurl,$scope,$accesstoken,$refreshtoken,$accesstokenexpiry) to encrypted buffer xOAUTH2.xKey is a 256 bit AES encryption key.Returns true if successful
$setauthcode$setauthcode(cAuthCode) Only applicable to kOW3OAUTH2authFlowManualCode and kOW3OAUTH2authFlowManualCodeWithPKCE,when $authorize() thread is waiting for authorization code.Called from the application to supply the pasted authorization code
$setsecureoptions$setsecureoptions([bVerifyPeer=kTrue,bVerifyHost=kTrue,cCertFile='',cPrivKeyFile='',cPrivKeyPassword='']) sets the options that affect how secure connections are established (the options do not apply to SFTP)
$tokensrefreshed$tokensrefreshed() Method called to tell the worker that the access token and possibly the access token expiry and the refresh token have been refreshed