iink SDK Web

Answered

Integration of rest api in android native app

I am trying to integrate the web rest API in the android project, before that I am trying to run in postman but I am getting the error {     "code": "access.not.granted",     "message": "Access not granted" } ,I have given the application key and hmac key from the application page which I have created  and can you please provide me android project sample with rest api integrated.


Best Answer

Dear Yahya,


the way to compute the hmac key is all indicated in this link: https://developer.myscript.com/support/account/registering-myscript-cloud/#computing-the-hmac-value


You can also refer to the source of the MyScriptJS library: https://github.com/MyScript/MyScriptJS:

-the src\recognizer\CryptoHelper.js file contains a computeHmac function

-then, you can refer to other files, such as src\recognizer\rest\v3\Cdkv3RestTextRecognizer.js that show how to compute the input data with the computeHmac function


Best regards,


Olivier


Dear Yahya,


currently, doing a simple REST request on Android is not different than on any other plateform.


Just format it properly, and post it to our server. If your postman request works fine, it should not be different on Android:

https://stackoverflow.com/questions/8267928/android-rest-client-sample

https://developer.myscript.com/docs/interactive-ink/1.3/web/rest/architecture/


Best regards,


Olivier

thanks for the reply Olivier, what my question I do know how to integrate api ,but I was asking more specific to MyScript rest api sample in android, because I need to provide the request body as well response body based on json,thanks.


Dear Yahya,


I am not sur to understand what you mean.


Usually, the "Access not granted" error message occurs when the hmac key is not properly computed.


In a first time, you can disable the hmac key in your dahsboard, so that you should no longer get the error message: 

https://developer-support.myscript.com/support/discussions/topics/16000026525

https://developer-support.myscript.com/support/discussions/topics/16000028017


If this work, in a second time, you shall compute it as follows: https://developer.myscript.com/support/account/registering-myscript-cloud/#computing-the-hmac-value


Best regards,


Olivier

Thanks for the response, So it works now as I disabled the HMAC in my cloud application pages, my question is it okay if we use the hmac key and app key provided in the application please refer image or I have to compute the HMAC with the function provided, if the answer is yes that I need to compute please provide a snippet how as we need to make the project go live in coming days.

image

Answer

Dear Yahya,


the way to compute the hmac key is all indicated in this link: https://developer.myscript.com/support/account/registering-myscript-cloud/#computing-the-hmac-value


You can also refer to the source of the MyScriptJS library: https://github.com/MyScript/MyScriptJS:

-the src\recognizer\CryptoHelper.js file contains a computeHmac function

-then, you can refer to other files, such as src\recognizer\rest\v3\Cdkv3RestTextRecognizer.js that show how to compute the input data with the computeHmac function


Best regards,


Olivier