| | 30 | === Python === |
| | 31 | |
| | 32 | `mayfirstAuth` is a simple python module (currently only installed on `mcchesney`), source below. It allows a writer of any python script to easily query the login-service. |
| | 33 | |
| | 34 | '''Usage:''' |
| | 35 | |
| | 36 | {{{ |
| | 37 | #!/usr/bin/python |
| | 38 | |
| | 39 | from mayfirstAuth import auth |
| | 40 | |
| | 41 | username = 'YOUR-USER-NAME' |
| | 42 | password = 'YOUR-PASSWORD' |
| | 43 | |
| | 44 | check = auth(username, password) |
| | 45 | |
| | 46 | if check == "0": |
| | 47 | print 'Login success' |
| | 48 | else |
| | 49 | print 'Login failure' |
| | 50 | }}} |
| | 51 | |
| | 52 | |
| | 53 | '''Source:''' |
| | 54 | |
| | 55 | {{{ |
| | 56 | #!/usr/bin/python |
| | 57 | |
| | 58 | import requests |
| | 59 | |
| | 60 | # set the login service URL |
| | 61 | url = 'https://id.mayfirst.org:8080/check' |
| | 62 | # this python lib uses a standard id |
| | 63 | appid= 'THESTRINGOFTHEAPPID' |
| | 64 | |
| | 65 | |
| | 66 | def auth(username, password): |
| | 67 | values = {'user' : username, |
| | 68 | 'password' : password, |
| | 69 | 'app_id' : appid} |
| | 70 | |
| | 71 | req = requests.post(url, data=values) |
| | 72 | is_valid_user = req.text |
| | 73 | |
| | 74 | if is_valid_user == "yes": |
| | 75 | return "0" |
| | 76 | return "1" |
| | 77 | |
| | 78 | }}} |
| | 79 | |
| | 80 | |
| | 81 | === PHP === |