wintron Posted March 2, 2016 Share Posted March 2, 2016 Hello! First post to this forum! I just created my first workflow, which I'd like to share with my team. Problem is, my workflow includes a script which references a private API key, which I would rather not share with the team. Is there any way I can share the workflow, without exposing the script's API key? For instance, by replacing the API key in the script with a reference to an environment variable instead? Appreciate the assistance. Many thanks! Steve Link to comment
deanishe Posted March 3, 2016 Share Posted March 3, 2016 (edited) There's little point using environmental variables, as Alfred doesn't use your (shell) environment. Apps use launchd's environment, which is pretty much empty. Your best bet is to store user-specific settings in the place Alfred expects you to: ~/Library/Application Support/Alfred 2/Workflow Data/YOUR.BUNDLE.ID Anything you put in the workflow directory gets deleted when the user updates the workflow. If you're using Python, this library will help. It can even store the API key in Keychain for you. To do it "ghetto" style, set up your workflow to run bash scripts and then call Python scripts from the Script box like in a shell (this is a good practice anyway). You can then set the envvar in the wrapper: [[ -f "$HOME/.workflow_api_key" ]] && { export API_KEY=$(cat "$HOME/.workflow_api_key") } /usr/bin/python myscript.py --option "{query}" Edited March 3, 2016 by deanishe Link to comment
wintron Posted March 4, 2016 Author Share Posted March 4, 2016 Alfred-Worflow is perfect, many thanks for the pointers! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now