This post will be focus on the configuration that needs to be set up for your module to be able to work completely.
The module works with a JSON file that will keep track of your different credential for the usage of Adobe IO.
You should have realized the first steps described on this article about setting Adobe IO JWT authentication. At least, having :
- The private key (file call privatekey.key)
- Your organization ID
- Your API Key
- Your tech id
- Your secret
Once you have these information available, you can start using the module.
Installing the module & requesting configuration
You can import the module by having it in the folder you are working on, or by having it in your python installation, inside the Python37/Lib folder. I usually chose the latter, as I just need to have the module at one place and I call always call it.
Once you have import the module, I have created an helper function to save your configuration. It will enable you to place all the information in one place and just import it later on to set your environment.
Let’s see how it looks :
import pyaum
pyaum.createConfigFile() ## will create a file name config.json in your folder.
Function createConfigFile(verbose=False)
This function will create the configuration file, by chosing verbose=True, it will print where the file has been created. The file will be named : config_admin.json.
The config file will look like this :
{
"org_id": "<orgID>",
"api_key": "<APIkey>",
"tech_id": "<something>@techacct.adobe.com",
"secret": "<YourSecret>",
"pathToKey": "<path/to/your/privatekey.key>"
}
You will have to replace the different elements with the appropriate values in order to make this file usable.
Importing the config file
As you may have realized with my different other API, you can import the config file directly in the module and it will set all of your elements as needed for the different requests.
In this module, the function is called importConfigFile. It is taking only one argument, the path to your “config_admin.json” file.
After importing the file, you can verify the information by looking into the _org_id or _api_key variable to make sure they are updated.
How to import it :
pyaum.importConfigFile('config_admin.json') ## will import the file and update the variable with the information you have provided in the document.
## To verify
pyaum._org_id ## Should return your value
pyaum._api_key ## Should return your value
Once the config file has been filled, imported and those dimensions have been updated, and only once, you can start use the different other method available.
Generating your token
The module holds its own JWT generation. You will see later that it is not necessary to generate your token but I give you the opportunity to do so if you want to generate it.
Normally all of the methods attached to this module and requesting the API will automatically generate the token (or update it) if require.
You can generate your token by calling the retrieveToken function.
function retrieveToken
This function takes only one argument, verbose, if you set it to True, it will print the expiration date of the token and where this token has been saved, in case you want to re-use it. You can access the date limit of the token by using the “_date_limit” variable created in the module.
token = pyaum.retrieveToken() ## will generate a token.
pyaum._date_limit ## will return the timestamp in second of the date limit of the token. Default 0.
I hope that this introduction was good enough to let you started on this module.
On this serie, you may want to read those articles:
Articles | Comments |
Adobe IO : JWT authentication | How to create JWT authentication with OpenSSL and python |
Adobe IO : User Management : Introduction | What you need to know about this module |
Adobe IO : User Management : Configuration | What do you need to have for this module. |
Adobe IO : User Management : retrieve information | How to retrieve the information currently held on your adobe admin console. |
Adobe IO : User Management : Create and Remove Users and Users Groups | How to create and remove users and user groups. |
Adobe IO : User Management : User Group Class | Discover how you can handle the different group with the python class available |
Adobe IO : User Management : Other functionnalities | Other functionalities that are included in this python module and that can be quite usefule |