Authentication


MD5 Digest: For this method of authentication, the Sprint Developer Sandbox API's use a signature which is comprised of the alphabetized parameters of the service you wish to access and the shared secret appended to the end.

To generate the signature for a sample location call:

																																									
http://sprintdevelopersandbox.com/developerSandbox/resource/v1/location.txt?
timestamp=2009-10-01T12:00:00CDT&mdn=8005554679&key=ABCD123XYZ&
						
						

You would take the md5 of:

							
MD5("keyABCD123XYZmdn8005554679timestamp2009-10-01T12:00:00CDTSECRET") 
						    																																																																																			  

Notes

  • Timestamp: The timestamp is formatted as ISO-8601.
    • # [YYYY]-[MM]-[DD]T[HH]:[MM]:[SS][ZZZ] [hh] refers to a zero-padded hour between 00 and 23 (where 00 is only used to notate midnight at the start of a calendar day).
  • Secret: Your account secret can be found on the user management page under the key.

Need more, thanks to the Phone Emulator you can view how signing your requests will work. Click here to try it for yourself.

Examples:

Java (Click to view)
						
public static String convertMapToURLStr(TreeMap paramMap, String secret){
	        StringBuffer urlBuffer = new StringBuffer();
	        for (Object key : paramMap.keySet()) {
        		if(key!=null) {
					String keyStr = (String)key;
					urlBuffer.append(keyStr);
					urlBuffer.append(paramMap.get(keyStr));
				}
			}
			urlBuffer.append(secret);        
			return MD5Sum.computeSum(urlBuffer.toString());
		}
						
						

  • The MD5Sum libraries can be downloaded here.
  • Description of the MD5Sum java library can be found here

Java-Script (Click to view)
							
signParams: function(params, secret){
	var sortKeyValuePairs = function(){
	var keys    = [];
	var return_var = [];
	$.each(params, function(key){keys.push(key);});
	$.each(keys.sort(), function(key){
		return_var.push(keys[key]);
		return_var.push(params[keys[key]]);
	});
	return return_var;
	}
	var message = sortKeyValuePairs(params);
	var signature = hex_md5(message.join("") + secret);
	return $.extend(params, {sig: signature});
}
							
						

The MD5 libraries can be downloaded here.