My setup is as follows:
I make API calls from python scripts activated in excel, using the wonderful xlwings.
This enables complex data extraction and transformation workflows to be coded in nice python instead of annoying VBA. It also makes these workflows available to non-coding users at the click of an embedded button.
My problem:
My API calls used hardcoded API keys in the past. This is a big security no-no. Now my API calls need to go through OIDC (OAuth2) authentication in Azure AD.
My questions:
Is it possible to trigger OIDC authentication (in Azure AD) from a local Python script?
Where could I securely store my client secret in such a setup?
Yes you can do this. You don't say which APIs you are calling but any of them act the same.
There are two types of authentication: interactive and non-interactive. You'll need to describe the one you want, but since you're concerned about hard-coded keys, let's assume that you want interactive.
This means that when a user wants to access the data, the user is prompted for credentials in a browser. An access token is returned to the application which is then used to call the APIs. No hardcoded keys are used and the token expires after a period of time.
You can get started by referring to this documenation: https://learn.microsoft.com/en-us/azure/developer/python/azure-sdk-authenticate
I have a Swagger JSON definition file. I would like to generate Python client binding for it. I would like to generate it as part of my development cycle, i.e., every time the definition changes I can run a script locally to regenerate my client
I am aware of Swagger Editor and Swagger Online Generators but they are no satisfying my needs:
both methods rely on an external service I need to call
as result I am getting .zip file I need to unzip - that makes whole process more complex.
I remember times when I could generate Java client binding for SOAP service running Apache CXF locally. Is there something like that for Swagger? I've seen there's an option to clone the whole swagger-codegen project, for all possible programming languages, but that seems like an overkill. Is there another option?
How companies are handling issue like mine?
I've used https://github.com/OpenAPITools/openapi-generator
You don't need to clone the whole repository, just download the JAR file and use it to generate the client/server.
Is it possible to setup the App Engine SDK on my local machine to use the live datastore while developing? Sometimes it's just easier for my workflow to work live.
If not, is there an easy way to download or sync the live data to development machine?
Thanks!
TL;DR: We do not support having the dev_appserver use the real app-engine datastore. Even with the suggested use of "remote_api", AFAIK, the dev_appserver does not know how to use it.
If you really want to make this work, you could write your own low-level API and have your own datastore abstraction that uses your API instead of the actual datastore, however this is a non trivial amount of work.
Another option is to have a servlet that can pre-populate your dev datastore with the data you need from checked in files. The checked in raw data could be non-real data or obfuscated real data. At dev_appserver startup, you hit this URL and your database becomes pre-populated with data. If you take this route, you get the bonus of not operating on your live data with dev code.
HTH!
Instead of "touching" live data from the development server I'd recommend downloading a copy of all your production data locally with appcfg.py download_data/upload_data if you wish to move changes from development to production you can explicitly use the same commands to override existing entities.
I am making a simple sqlite database for storing some non-sensitive client information. I am very familiar with python+sqlite and would prefer to stick with this combo on this project. I would like to create an simple GUI interface for data entry and searching of the database... something very similar to what MS Access provides. I want my wife to be able to enter/search data easily, so PHPmyadmin style things are out of the question.
I understand I could just give in and get MS Access, but if reasonbly possible would rather just write the code myself so it will run on my computers (*nix) and is flexible (so I can later integrate it with a web application and our smart phones.)
Can you developers recommend any interfaces/packages/etc (preferably pythonic) that can accomplish this with reasonable ease?
Thanks!
Since you're interested in future integration with a web application, you might consider using a Python web framework and running the app locally on your machine, using your web browser as the interface. In that case, one easy option would be web2py. Just download, unzip, and run, and you can use the web-based IDE (demo) to create a simple CRUD app very quickly (if you really want to keep it simple, you can even use the "New application wizard" (demo) to build the app). It includes its own server, so you can run your app locally, just like a desktop app.
You can use the web2py DAL (database abstraction layer) to define and create your SQLite database and tables (without writing any SQL). For example:
db = DAL('sqlite://storage.db')
db.define_table('customer',
Field('name', requires=IS_NOT_IN_DB(db, 'customer.name')),
Field('address'),
Field('email', requires=IS_EMAIL()))
The above code will create a SQLite database called storage.db and create a table called 'customer'. It also specifies form validators for the 'name' and 'email' fields, so whenever those fields are filled via a form, the entries will be validated ('name' cannot already be in the DB, and 'email' must be a valid email address format) -- if validation fails, the form will display appropriate error messages (which can be customized).
The DAL will also handle schema migrations automatically, so if you change your table definitions, the database schema will be updated (if necessary, you can turn off migrations completely or on a per table basis).
Once you have your data models defined, you can use web2py's CRUD system to handle all the data entry and searching. Just include these two lines (actually, they're already included in the 'welcome' scaffolding application):
from gluon.tools import Crud
crud = Crud(db)
And in a controller, define the following action:
def data():
return dict(form=crud())
That will expose a set of pre-defined URLs that will enable you to create, list, search, view, update, and delete records in any table.
Of course, if you don't like some of the default behavior, there are lots of ways to customize the CRUD forms/displays, or you can use some of web2py's other forms functionality to build a completely custom interface. And web2py is a full-stack framework, so it will be easy to add functionality to your app as your needs expand (e.g., access control, notifications, etc.).
Note, web2py requires no installation or configuration and has no dependencies, so it's very easy to distribute your app to other machines -- just zip up the entire web2py folder (which will include your app folder) and unzip it on another machine. It will run on *nix, Mac, and Windows (on Windows, you will either need to install Python or download the web2py Windows binary instead of the source version -- the Windows binary includes its own Python interpreter).
If you have any questions, there's a very helpful and responsive mailing list. You might also get some ideas from some existing web2py applications.
I normally use GTK+ that has well documented Python bindings.
The biggest advantage is that you can use a fairly intuitive GUI editor (Glade) and automagically link callbacks to events (to be honest most other major graphical toolkits have this possibility too, like for example QT, but my perception is that GTK+ enjoys wider adoption in the Python community). EDIT: additionally GTK is used by Gnome and many other desktop environments (KDE uses QT though).
That said, if all you need is truly just data insertion from a trusted person, you could use something already done like SQLite manager (it's a FireFox plugin).
Radically alternative solution: use django and you can literally pass from reading the tutorial to have your app up and running in a matter of hours, inclusive of user authentications, back-end administrative interface etc. (your project is exactly what I did with it to allow my wife to insert expenses in our family budget).
Django is written in Python and you can use SQLite as a back-end.
Coming from a java background I'm used to having a bunch of properties files I can swap round at runtime dependent on what server I'm running on e.g. dev/production.
Is there a method in python to do similar, specifically on Google's App Engine framework?
At the minute I have them defined in .py files, obviously I'd like a better separation.
You can:
edit records in the datastore through the dashboard ( if you really have to )
upload new scripts / files ( you can access files in READ-ONLY )
export a WEB Service API to configuration records in the datastore ( probably not what you had in mind )
access a page somewhere through an HTTP end-point
I don't see what is wrong with using python files to configure your application (apart from cultural issues :) ). In fact I have an issue with frameworks which don't allow me to script the configuration parameters.
That said, please have a look http://aaron.oirt.rutgers.edu/myapp/docs/W1100_2300.GAEDeploy for
a discussion of how to configure WHIFF application resources to configure applications to work in and out of the GAE framework in a portable manner.