Authentication

To use DynaCrop services, you need an API key. It is an ultimate authentication passcode that you can pass to the SDK. We’ll need the SDK Config helper class.

[1]:
from dynacrop import Config

You can choose to authenticate everytime before utilizing DynaCrop functions (executing API requests) in your code. To do so, initialize the Config class and assign your API key to the api_key keyword parameter.

[2]:
config = Config()
config.api_key = 'my_api_key'

API key can be added to your user configuration file - config.json, where other configuration data for a user also reside. It will be located in the .dynacrop folder in your user root directory. Beware, that after saving the API Key, this file essentially stores credential data.

You can save the API key like this:

[3]:
config.save()

After storing the API key, you no longer have to use the authentication code structure above. If you want to act as a different user on the fly, at the beginning of your script, you simply initialize Config with a different api_key parameter.

[4]:
config = Config()
config.api_key = 'some_other_api_key'

Unless you save the above configuration, the config.json file remains unchanged.