This simple python tool downloads .csv inventory stocktakes from a Mail server and imports to webims-backend-api. It exploits Inventory import
API to import inventory data. This tool must be executed per warehouse import job.
- Install all required libraries and launch main.py
- Enter sync settings, fetch frequency (in seconds) and mail server folder name.
- Define string to look for in the subject line. Any incoming mail with subject containing the entered string will be processed.
- Enter API host 'https://hostname'.
- Obtain sessionId via Users
login
API and enter session key. It is recommend to use managed service accounts to avoid having expired sessions. - Obtain warehouse ID via
read
API and enter warehouse ID. - Import job will be executed for any incoming mail with .csv attachments as per defined subject filter.
- Enter mailbox settings. Supported configurations include IMAP and Microsoft Outlook (recommended, see instructions below).
To allow authentication you first need to register your application at Azure App Registrations.
- Login at Azure Portal (App Registrations)
- Create an app. Set a name.
- In Supported account types choose "Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com)".
- Set the redirect uri (Web) to: https://login.microsoftonline.com/common/oauth2/nativeclient and click register. This needs to be inserted into the "Redirect URI" text box as simply checking the check box next to this link seems to be insufficent. This is the default redirect uri used by this library, but you can use any other if you want.
- Write down the Application (client) ID. You will need this value.
- Under "Certificates & secrets", generate a new client secret. Set the expiration preferably to never. Write down the value of the client secret created now. It will be hidden later on.
- Under API Permissions, add delegated permissions for the following Microsoft Graph scopes (Mail.ReadWrite, offline_access, User.Read).
- Then you need to login for the first time to get the access token that will grant access to the user resources.