Skip to content

Instantly share code, notes, and snippets.

@qpleple
Created May 4, 2018 14:51
Show Gist options
  • Select an option

  • Save qpleple/2691344ab8e76b7897c733cfd0035981 to your computer and use it in GitHub Desktop.

Select an option

Save qpleple/2691344ab8e76b7897c733cfd0035981 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import hashlib\n",
"def get_md5(s):\n",
" return hashlib.md5(s).hexdigest()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://localhost:8000/rest/query/Sylob_01/resultat?limite=1000&valeurNumeriqueFormatee=false&Code+de+l%27article=\n",
"login_webservice = 28ad0ecd8169f50b5f8242026be51391\n",
"passwd_webservice = 97ac94d55f6e04b3490877af1ec61931\n",
"Md5 a426698e15010475dae737fb8fdd5632\n",
"401\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html\n",
" InsecureRequestWarning)\n"
]
}
],
"source": [
"import requests\n",
"\n",
"url = \"https://localhost:8000/rest/query/Sylob_01/resultat?limite=1000&valeurNumeriqueFormatee=false&Code+de+l%27article=\"\n",
"login = 'quentin'\n",
"database = 'Bac a sable 2'\n",
"passwd = 'quentin!'\n",
"session = '00001'\n",
"\n",
"login_webservice = get_md5(login + '_' + database + '_' + session)\n",
"passwd_webservice = get_md5(passwd)\n",
"\n",
"headers = {\n",
" 'Authorization': \"Md5 \" + get_md5(login_webservice + ':' + passwd_webservice),\n",
" 'Cache-Control': \"no-cache\",\n",
"}\n",
"\n",
"r = requests.get(url, verify=False, headers=headers)\n",
"\n",
"print url\n",
"print \"login_webservice =\", login_webservice\n",
"print \"passwd_webservice =\", passwd_webservice\n",
"print r.request.headers['Authorization']\n",
"print r.status_code"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment