Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Login to an API using ssl certificate
-
Hello, I'm new to Pythonista and file handling on iPad.
I have a script that works on Windows which I have managed to copy into Pythonista. It uses requests.post to call an api to login using ssl.
I can't work out how to copy the ssl certificate and key files to the iPad so that I can pass them to the API using the cert parameter.
Could I humbly request some help with what is probably blindingly obvious but which I can't see?
-
You can copy the files in a number of ways. Dropbox, email as plaintext, ftp (either ftplib, or using stash ftp command). you could host them on a webserver, or create a private gist (then use the share menu to share to pythonista).
-
Thank you for responding. But I'm afraid I need a little more info.
If I have the files on dropbox, say they are called uname.crt and uname.pem, how would I specify the path in the cert parameter?
-
Try putting them in the same directory as the script you want to run. https://gist.github.com/omz/fb180c58c94526e2c40b You can get the iOS path to the current script with:
print(__file__)
. -
Thanks, I'll try that. Because of other commitments it may be Saturday before I can have a go though so no feedback for a bit sorry. Cheers in advance!
-
The script at github appears to be Python 2.7 and I'm having great difficulty converting to 3.5. Can you point me to a 3.5 version please?
-
Under the wrench icon in Pythonista there is an option that does the 2 to 3 conversion for you.
-
@chrisiwyg If you can't get the script converted to Python 3 for whatever reason, you can also just use the Python 2.7 interpreter. I mention this because a lot of people seem to think that Pythonista 3 only supports Python 3.5, but that's not the case.
To override the default interpreter just once, simply tap and hold the "run" button, and a "run with Python 2.7" option will appear. Alternatively, you can insert
#! python2
as the first line of the script to tell Pythonista that it should run it with Python 2.7 by default. -
Thank you JonB for suggesting Dropbox, ccc for suggesting how to get the path from file and thank you omz for describing how to run python 2 in pythonista 3.
My script now works on iPad, a transition which I thought would be much harder to achieve than it was.
Pythonista was recommended to me by someone who actually works in IT, not a recreational programmer like myself. In my short time using it I must say that I'm impressed by how easy it is to use. I love how the script editor works. And this forum is the business!