Registering with MyScript Cloud
In order to use MyScript Cloud, you are required to register. Only requests from valid users will be considered by the server.
Registration
To become a valid user, follow the below procedure:
- Create an account on the Developer Portal with your social network account (Facebook, Google or Live) or with your email address.
- If you used your email address, you need to confirm your registration by clicking on the link you received by mail. Access to MyScript Cloud is granted with a 2,000 request/month free quota.
- Log in and follow the instructions in the Getting started section to have your keys resent by email.
Read carefully and store the mail you will receive.
Pricing
MyScript Cloud pricing model is based on the volume of requests.
Using the REST API, a request is simply a call to MyScript servers.
Using the WebSockets API, a request includes all the exchanges between the āsocket openā and the āsocket closeā (or the detection of a closed socket by the server). It is limited to 5 minutes, 3 minutes if there are no exchanges. Within the time limit, new requests are counted each time new content is sent after 4 successful clear operations.
For the current pricing, see the Pricing section.
Identification of your application
If you are working on code samples, your application and HMAC keys have to be pasted in the definition strings of the code samples.
Replace the existing keys (applicationKey
and hmacKey
) and run the code.
If you are working on your own application, both the application key and the HMAC value have to be part of your requests.
See below examples to compute your HMAC value in REST and WebSocket requests. Note that the difference lies in the jsonInput
provided.
In REST mode, you need to compute the HMAC on the input sent to the server.
In WebSockets mode, you need to answer the challenge message sent by the server with the HMAC value of the challenge.
Please note that if you are using iinkJS, those computations will be handled by the library.
You will get access to usage statistics at https://cloud.myscript.com/#/user/counters.
Adding extra application
You may want to manage several applications linked to the same MyScript account. In that case, you can configure extra applications with the MyScript Cloud administration interface. Click the Create application button and enter a name and a description. You will be able to access the usage statistics, manage your applications and generate or revoke your application and hmac keys.
Computing the HMAC value
Hash-based message authentication code is a specific type of message involving a cryptographic hash function and a secret cryptographic key. See below a JavaScript example, assuming that CryptoJS is accessible from the environment. Please google āHMAC computationā to get examples in the programming language of your choice.
/**
* 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 in REST mode, challenge in WebSocket mode
*
*/
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);
}
}
Configuring your application for production
Once your application is ready but before going live, please read and configure your application such as recommended in this section.