PyWebtasks: A Python wrapper for Auth0's Webtasks API
Installation
To install PyWebtasks, simply:
$ pip install pywebtasks
Usage
Create a new webtask token:
>>> from pywebtasks import tokens
>>> wt_token = tokens.create('your_auth_webtask_token')
To view your user's auth webtask token go to the webtask.io token section.
To revoke a webtask token:
>>> tokens.revoke(wt_token)
Run a webtask from a string:
>>> import pywebtasks
>>> js_code = '''return function (context, cb) {
cb(null, "Hello, JS world!");
};
'''
>>> req = pywebtasks.run(js_code,
'a_wt_container_name-0',
'a_webtask_token')
>>> req.content
'Hello, JS world!'
If you want to run the content of a source code file (for example, javascript.js), you can use the run_file
function:
>>> req = pywebtasks.run_file('/path/to/a/file.js',
'a_wt_container_name-0',
'a_webtask_token')
>>> req.content
'Hello, JS world!'