Changes between Version 7 and Version 8 of login-service


Ignore:
Timestamp:
Mar 10, 2016, 12:31:27 PM (4 years ago)
Author:
Nat Meysenburg
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • login-service

    v7 v8  
    1717Writing a client to interface with the login service is relatively easy.
    1818
    19 Here are a few examples:
    20 
     19=== Bash ===
    2120{{{
    2221#!/bin/bash
     
    2928}}}
    3029
     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
     39from mayfirstAuth import auth
     40
     41username = 'YOUR-USER-NAME'
     42password = 'YOUR-PASSWORD'
     43
     44check = auth(username, password)
     45
     46if check == "0":
     47    print 'Login success'
     48else
     49    print 'Login failure'
     50}}}
     51
     52
     53'''Source:'''
     54
     55{{{
     56#!/usr/bin/python
     57
     58import requests
     59
     60# set the login service URL
     61url = 'https://id.mayfirst.org:8080/check'
     62# this python lib uses a standard id
     63appid= 'THESTRINGOFTHEAPPID'
     64
     65
     66def 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 ===
    3182{{{
    3283<?php