Registration

In order to use MyScript Cloud, users are required to register. Only requests from valid users will be considered by the HTTP server. To become a valid user, follow the below procedure:

  1. Create an account on the Developer Portal with your social network account (Facebook, Google or Live) or with your email address.
  2. If you used your email address, you need to confirm your registration by clicking on the link you received by mail.
  3. Login to your account, click DOCS in the top menu, then CDK Downloads in the left menu.
  4. Check the box I want a free 90-day developer license for MyScript Cloud Development Kit and click I ACCEPT.

Read carefully and store the mail you will receive.

Registration keys and values

If you are working on code samples, the application key and the HMAC key have to be pasted in the definition strings of code samples. Replace the existing keys (var applicationKey and var hmacKey) and run the code.

If you are working on your own application, then the application key and the HMAC value have to be part of your JSON request.

The HMAC key requires the use of a function to obtain the hidden HMAC value to be sent.

See below examples to compute your HMAC value in REST and WebSocket requests. Note that the difference between both lies in the jsonInput function.

Computing the HMAC value in REST requests

/**
 * Compute required value to return to the server with hmac SHA512 hash algorithm
 * It prevents from man-in-the-middle key theft
 *
 * @applicationKey : applicationKey
 * @hmackey :hmacKey
 * @jsonInput: textInput, mathInput, shapeInput, musicInput or AnalyzerInput
 * 
 */
String computeHMAC(String applicationKey, String hmacKey, String jsonInput) {
    final String HMAC_SHA_512_ALGORITHM = "HmacSHA512";
    final String userKey = applicationKey + hmacKey;

    try {
        // get an hmac_sha512 key from the raw key bytes
        SecretKeySpec signingKey = new SecretKeySpec(userKey.getBytes(), HMAC_SHA_512_ALGORITHM);

        // get an hmac_sha512 Mac instance and initialize with the signing key
        Mac mac = Mac.getInstance(HMAC_SHA_512_ALGORITHM);
        mac.init(signingKey);

        // compute the hmac on input data bytes
        byte[] rawHmac = mac.doFinal(jsonInput.getBytes());

        return Hex.encodeHexString(rawHmac);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

Computing the HMAC value in WebSocket requests

/**
 * Compute required value to return to the server with hmac SHA512 hash algorithm
 * It prevents from man-in-the-middle key theft
 *
 * @applicationKey : applicationKey
 * @hmackey :hmacKey
 * @jsonInput: hmacChallenge
 * 
 */
String computeHMAC(String applicationKey, String hmacKey, String jsonInput) {
    final String HMAC_SHA_512_ALGORITHM = "HmacSHA512";
    final String userKey = applicationKey + hmacKey;

    try {
        // get an hmac_sha512 key from the raw key bytes
        SecretKeySpec signingKey = new SecretKeySpec(userKey.getBytes(), HMAC_SHA_512_ALGORITHM);

        // get an hmac_sha512 Mac instance and initialize with the signing key
        Mac mac = Mac.getInstance(HMAC_SHA_512_ALGORITHM);
        mac.init(signingKey);

        // compute the hmac on input data bytes
        byte[] rawHmac = mac.doFinal(jsonInput.getBytes());

        return Hex.encodeHexString(rawHmac);

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}