{% extends "layout.html" %} {% block content %}
| Method | Description |
|---|---|
| GET | Retrieves data from WBIA |
| PUT | Sets data in WBIA using specified items and the new values. PUT can also be used to update the state of WBIA by running algorithm subroutines |
| POST | Adds data to WBIA using new values |
| DELETE | Deletes data from WBIA using specified items |
Username: wbia
Password: wbia
Name: {{ app_name }}
Secret: {{ app_secret }}
Python Version:
def get_signature(key, message):
return str(hmac.new(key, message, sha1).digest().encode("base64").rstrip('\n'))
def get_authorization_header(url):
app_name = 'WBIA'
app_secret = 'CB73808F-A6F6-094B-5FCD-385EBAFF8FC0'
url = str(request.url)
hash_ = get_signature(app_secret, url)
header = '%s:%s' % (app_name, hash_, )
return header
C# Version:
private static string GetSignature(string key, byte[] messageToSendBytes)
{
var keyHMAC = new HMACSHA1(Encoding.ASCII.GetBytes(key));
var keyBytes = keyHMAC.ComputeHash(messageToSendBytes);
return Convert.ToBase64String(keyBytes);
}
public static string GetAuthorizationHeader(string url)
{
string appName = "WBIA";
string appSecret = "CB73808F-A6F6-094B-5FCD-385EBAFF8FC0";
var messageToSendBytes = Encoding.ASCII.GetBytes(url);
var secretKeySignature = GetSignature(appSecret, messageToSendBytes);
return string.Format("{0}:{1}", appName, secretKeySignature);
}
Javascript Version (using CryptoJS):
httpAuth = function() {
var getSignature = function(message, key) {
var hash = CryptoJS.HmacSHA1(message, key);
return CryptoJS.enc.Base64.stringify(hash);
}
return {
getAuthorizationHeader: function(url) {
var app_name = 'WBIA'
var app_secret = 'CB73808F-A6F6-094B-5FCD-385EBAFF8FC0'
var hash = getSignature(url, app_secret)
var header = app_name.concat(':', hash)
return header
},
}
}();
Java Version:
private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";
private static String getSignature(String key, byte[] messageToSendBytes) throws NoSuchAlgorithmException, InvalidKeyException {
SecretKeySpec keyHmac = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
mac.init(keyHmac);
return new String(Base64.encodeBase64(mac.doFinal(messageToSendBytes)));
}
public static String getAuthorizationHeader(String url) throws NoSuchAlgorithmException, InvalidKeyException {
String appName = "WBIA";
String appSecret = "CB73808F-A6F6-094B-5FCD-385EBAFF8FC0";
return appName + ":" + getSignature(appSecret, url.getBytes());
}
Request:
Name: WBIA
Secret: CB73808F-A6F6-094B-5FCD-385EBAFF8FC0
Method: GET
URL: {{ app_url }} * NOTE: The URL sent to the server includes the protocol and port.
Headers: {
'Authorization': '{{ app_auth }}'
}
Response: {
"status": {
"cache": -1,
"message": "",
"code": 200,
"success": true
},
"response": "testdb1"
}http://erotemic.github.io/wbia/wbia.control.html
http://erotemic.github.io/wbia/wbia.web.html
{% for (method, url) in rule_list['GET'] %}{{ method }} : {{ url }}
{% endfor %}{% for (method, url) in rule_list['PUT'] %}{{ method }} : {{ url }}
{% endfor %}{% for (method, url) in rule_list['POST'] %}{{ method }} : {{ url }}
{% endfor %}{% for (method, url) in rule_list['DELETE'] %}{{ method }} : {{ url }}
{% endfor %}