Text

Answered

swagger script API keeps returning access.not.granted (error code 401)

I am adding the application key shared with me over email by MyScript.

and using hmac string created using a hmac sha 512 algorithm online, using the payload and hmac key shared.

This is my request object.

{"configuration":{"export":{"jiix":{"strokes":false,"text":{"chars":false,"words":false}}},"lang":"en_US"},"contentType":"Text","height":21600,"strokeGroups":[{"strokes":[{"p":[],"t":[],"x":[18090,18104,18114,18114,18123,18123,18123,18123,18123,18123,18123,18123,18116,18116,18094,18072,18036,17988,17929,17860,17788,17711,17633,17550,17465,17380,17294,17209,17125,17044,16967,16898,16836,16780,16730,16686,16648,16616,16590,16570,16558,16558,16549,16549,16549,16558,16563,16570,16583,16601,16627,16658,16696,16738,16784,16833,16884,16934,16983,17030,17071,17106,17136,17158,17175,17187,17199,17209,17221,17238,17257,17281,17310,17341,17375,17415,17457,17503,17552,17604,17663,17732,17810,17899,17995,18096,18199,18306,18412,18517,18622,18723,18820,18912,18995,19070,19139,19200,19256,19307,19350,19389,19420,19445,19465,19479,19479,19490,19490,19477,19456,19423,19378,19322,19260,19260],"y":[17940,17935,17929,17929,17923,17923,17923,17923,17923,17923,17923,17923,17911,17911,17886,17861,17823,17774,17715,17647,17569,17482,17392,17299,17205,17112,17010,16905,16798,16692,16592,16498,16410,16330,16258,16195,16143,16101,16071,16050,16039,16039,16034,16034,16034,16050,16064,16088,16121,16162,16212,16268,16327,16390,16457,16525,16594,16660,16722,16777,16825,16862,16888,16904,16911,16911,16905,16894,16878,16858,16836,16811,16782,16752,16721,16689,16658,16628,16594,16559,16523,16482,16440,16395,16347,16297,16245,16189,16134,16076,16021,15969,15922,15878,15839,15803,15768,15737,15707,15681,15656,15633,15613,15593,15576,15564,15564,15552,15552,15549,15547,15548,15551,15558,15570,15570]},{"p":[],"t":[],"x":[16709,16709,16703,16703,16703,16703,16703,16703,16714,16729,16752,16782,16819,16862,16913,16971,17036,17111,17190,17278,17371,17466,17562,17656,17747,17832,17913,17986,18052,18112,18161,18204,18239,18265,18285,18297,18301,18299,18299,18276,18250,18210,18152,18086,18011,17935,17864,17798,17742,17695,17656,17627,17607,17592,17583,17583,17572,17572,17572,17559,17550,17535,17515,17490,17460,17427,17388,17346,17300,17251,17199,17145,17090,17035,16980,16925,16872,16819,16770,16722,16678,16634,16592,16549,16509,16473,16440,16414,16391,16373,16362,16362,16352,16352,16352,16352,16352,16362,16374,16392,16419,16457,16507,16567,16635,16710,16792,16887,16993,17105,17220,17333,17439,17538,17629,17713,17793,17868,17937,18001,18057,18109,18153,18189,18214,18229,18236,18237,18237,18225,18206,18166,18102,18011,17894,17894],"y":[15246,15246,15237,15237,15237,15237,15237,15237,15227,15217,15204,15188,15171,15152,15130,15107,15079,15048,15015,14979,14944,14908,14872,14836,14798,14763,14727,14689,14655,14620,14588,14556,14525,14496,14470,14450,14435,14425,14425,14420,14426,14438,14458,14486,14519,14556,14592,14627,14658,14684,14704,14720,14733,14745,14755,14755,14764,14764,14764,14758,14753,14745,14731,14712,14687,14658,14623,14583,14539,14490,14440,14390,14343,14300,14262,14231,14205,14187,14177,14174,14178,14187,14199,14213,14227,14240,14252,14261,14267,14272,14275,14275,14279,14279,14279,14279,14279,14274,14267,14258,14244,14227,14206,14183,14156,14125,14094,14060,14027,13995,13962,13928,13893,13861,13832,13804,13778,13753,13728,13705,13685,13664,13645,13628,13612,13598,13587,13578,13578,13561,13550,13536,13518,13503,13492,13492]},{"p":[],"t":[],"x":[15937,15921,15921,15921,15921,15921,15915,15915,15917,15920,15924,15932,15942,15960,15983,16012,16050,16095,16148,16210,16279,16352,16431,16514,16597,16681,16767,16849,16931,17013,17089,17159,17223,17279,17325,17362,17389,17405,17405,17405,17405,17392,17365,17321,17256,17170,17170],"y":[13463,13458,13458,13458,13458,13458,13449,13449,13435,13425,13412,13398,13381,13364,13345,13328,13311,13293,13274,13251,13227,13203,13178,13153,13127,13104,13080,13060,13038,13017,12998,12981,12967,12954,12942,12932,12923,12915,12915,12915,12915,12914,12919,12925,12934,12947,12947]},{"p":[],"t":[],"x":[16134,16096,16065,16039,16015,15991,15967,15944,15922,15900,15877,15851,15824,15796,15771,15747,15727,15712,15700,15696,15695,15699,15706,15717,15730,15744,15759,15775,15794,15815,15841,15870,15902,15940,15984,16029,16074,16115,16150,16181,16207,16227,16243,16257,16269,16281,16292,16302,16311,16317,16319,16319,16315,16310,16305,16301,16297,16296,16296,16300,16309,16321,16339,16360,16384,16412,16441,16474,16511,16554,16600,16648,16699,16749,16803,16860,16921,16985,17052,17118,17184,17249,17313,17377,17441,17503,17563,17622,17679,17736,17793,17793],"y":[13166,13182,13197,13211,13222,13229,13232,13231,13226,13218,13206,13187,13162,13128,13085,13037,12986,12932,12880,12829,12777,12726,12675,12624,12575,12532,12495,12465,12442,12426,12416,12413,12417,12428,12446,12470,12496,12520,12539,12552,12560,12564,12562,12557,12547,12530,12507,12477,12439,12397,12354,12309,12264,12220,12173,12128,12083,12041,12000,11963,11931,11898,11869,11842,11818,11797,11781,11769,11759,11753,11750,11750,11754,11763,11777,11798,11825,11856,11892,11930,11970,12012,12054,12102,12152,12206,12265,12323,12386,12452,12522,12522]},{"p":[],"t":[],"x":[20122,20167,20206,20240,20270,20297,20317,20333,20343,20343,20343,20343,20343,20341,20332,20315,20287,20247,20192,20125,20048,19958,19857,19747,19630,19510,19388,19266,19144,19020,18899,18781,18672,18574,18489,18414,18345,18284,18230,18182,18141,18103,18068,18035,18005,17978,17955,17940,17930,17923,17921,17921,17917,17917,17917,17917,17917,17917,17917,17917,17917,17926,17926,17926,17926,17926,17926,17929,17929,17929],"y":[15176,15218,15256,15292,15325,15351,15371,15386,15395,15395,15395,15395,15395,15379,15359,15329,15289,15236,15171,15091,14998,14892,14773,14644,14498,14336,14161,13972,13778,13574,13369,13159,12948,12742,12540,12349,12170,12009,11860,11726,11606,11500,11410,11331,11264,11208,11165,11133,11109,11094,11082,11082,11072,11072,11072,11072,11072,11072,11072,11072,11072,11078,11078,11078,11078,11078,11078,11089,11089,11089]}]}],"width":29700,"xDPI":96,"yDPI":96}

The API keeps giving me 401 error.

I don't know what i am doing wrong.


CURL request


curl -X POST "https://cloud.myscript.com/api/v4.0/iink/batch" -H "accept: */*" -H "applicationKey: KEY" -H "hmac: HMAC_STRING" -H "Accept: List [ "text" ]" -H "Content-Type: application/json" -d "'{\"configuration\":{\"export\":{\"jiix\":{\"strokes\":false,\"text\":{\"chars\":false,\"words\":false}}},\"lang\":\"en_US\"},\"contentType\":\"Text\",\"height\":21600,\"strokeGroups\":[{\"strokes\":[{\"p\":[],\"t\":[],\"x\":[18090,18104,18114,18114,18123,18123,18123,18123,18123,18123,18123,18123,18116,18116,18094,18072,18036,17988,17929,17860,17788,17711,17633,17550,17465,17380,17294,17209,17125,17044,16967,16898,16836,16780,16730,16686,16648,16616,16590,16570,16558,16558,16549,16549,16549,16558,16563,16570,16583,16601,16627,16658,16696,16738,16784,16833,16884,16934,16983,17030,17071,17106,17136,17158,17175,17187,17199,17209,17221,17238,17257,17281,17310,17341,17375,17415,17457,17503,17552,17604,17663,17732,17810,17899,17995,18096,18199,18306,18412,18517,18622,18723,18820,18912,18995,19070,19139,19200,19256,19307,19350,19389,19420,19445,19465,19479,19479,19490,19490,19477,19456,19423,19378,19322,19260,19260],\"y\":[17940,17935,17929,17929,17923,17923,17923,17923,17923,17923,17923,17923,17911,17911,17886,17861,17823,17774,17715,17647,17569,17482,17392,17299,17205,17112,17010,16905,16798,16692,16592,16498,16410,16330,16258,16195,16143,16101,16071,16050,16039,16039,16034,16034,16034,16050,16064,16088,16121,16162,16212,16268,16327,16390,16457,16525,16594,16660,16722,16777,16825,16862,16888,16904,16911,16911,16905,16894,16878,16858,16836,16811,16782,16752,16721,16689,16658,16628,16594,16559,16523,16482,16440,16395,16347,16297,16245,16189,16134,16076,16021,15969,15922,15878,15839,15803,15768,15737,15707,15681,15656,15633,15613,15593,15576,15564,15564,15552,15552,15549,15547,15548,15551,15558,15570,15570]},{\"p\":[],\"t\":[],\"x\":[16709,16709,16703,16703,16703,16703,16703,16703,16714,16729,16752,16782,16819,16862,16913,16971,17036,17111,17190,17278,17371,17466,17562,17656,17747,17832,17913,17986,18052,18112,18161,18204,18239,18265,18285,18297,18301,18299,18299,18276,18250,18210,18152,18086,18011,17935,17864,17798,17742,17695,17656,17627,17607,17592,17583,17583,17572,17572,17572,17559,17550,17535,17515,17490,17460,17427,17388,17346,17300,17251,17199,17145,17090,17035,16980,16925,16872,16819,16770,16722,16678,16634,16592,16549,16509,16473,16440,16414,16391,16373,16362,16362,16352,16352,16352,16352,16352,16362,16374,16392,16419,16457,16507,16567,16635,16710,16792,16887,16993,17105,17220,17333,17439,17538,17629,17713,17793,17868,17937,18001,18057,18109,18153,18189,18214,18229,18236,18237,18237,18225,18206,18166,18102,18011,17894,17894],\"y\":[15246,15246,15237,15237,15237,15237,15237,15237,15227,15217,15204,15188,15171,15152,15130,15107,15079,15048,15015,14979,14944,14908,14872,14836,14798,14763,14727,14689,14655,14620,14588,14556,14525,14496,14470,14450,14435,14425,14425,14420,14426,14438,14458,14486,14519,14556,14592,14627,14658,14684,14704,14720,14733,14745,14755,14755,14764,14764,14764,14758,14753,14745,14731,14712,14687,14658,14623,14583,14539,14490,14440,14390,14343,14300,14262,14231,14205,14187,14177,14174,14178,14187,14199,14213,14227,14240,14252,14261,14267,14272,14275,14275,14279,14279,14279,14279,14279,14274,14267,14258,14244,14227,14206,14183,14156,14125,14094,14060,14027,13995,13962,13928,13893,13861,13832,13804,13778,13753,13728,13705,13685,13664,13645,13628,13612,13598,13587,13578,13578,13561,13550,13536,13518,13503,13492,13492]},{\"p\":[],\"t\":[],\"x\":[15937,15921,15921,15921,15921,15921,15915,15915,15917,15920,15924,15932,15942,15960,15983,16012,16050,16095,16148,16210,16279,16352,16431,16514,16597,16681,16767,16849,16931,17013,17089,17159,17223,17279,17325,17362,17389,17405,17405,17405,17405,17392,17365,17321,17256,17170,17170],\"y\":[13463,13458,13458,13458,13458,13458,13449,13449,13435,13425,13412,13398,13381,13364,13345,13328,13311,13293,13274,13251,13227,13203,13178,13153,13127,13104,13080,13060,13038,13017,12998,12981,12967,12954,12942,12932,12923,12915,12915,12915,12915,12914,12919,12925,12934,12947,12947]},{\"p\":[],\"t\":[],\"x\":[16134,16096,16065,16039,16015,15991,15967,15944,15922,15900,15877,15851,15824,15796,15771,15747,15727,15712,15700,15696,15695,15699,15706,15717,15730,15744,15759,15775,15794,15815,15841,15870,15902,15940,15984,16029,16074,16115,16150,16181,16207,16227,16243,16257,16269,16281,16292,16302,16311,16317,16319,16319,16315,16310,16305,16301,16297,16296,16296,16300,16309,16321,16339,16360,16384,16412,16441,16474,16511,16554,16600,16648,16699,16749,16803,16860,16921,16985,17052,17118,17184,17249,17313,17377,17441,17503,17563,17622,17679,17736,17793,17793],\"y\":[13166,13182,13197,13211,13222,13229,13232,13231,13226,13218,13206,13187,13162,13128,13085,13037,12986,12932,12880,12829,12777,12726,12675,12624,12575,12532,12495,12465,12442,12426,12416,12413,12417,12428,12446,12470,12496,12520,12539,12552,12560,12564,12562,12557,12547,12530,12507,12477,12439,12397,12354,12309,12264,12220,12173,12128,12083,12041,12000,11963,11931,11898,11869,11842,11818,11797,11781,11769,11759,11753,11750,11750,11754,11763,11777,11798,11825,11856,11892,11930,11970,12012,12054,12102,12152,12206,12265,12323,12386,12452,12522,12522]},{\"p\":[],\"t\":[],\"x\":[20122,20167,20206,20240,20270,20297,20317,20333,20343,20343,20343,20343,20343,20341,20332,20315,20287,20247,20192,20125,20048,19958,19857,19747,19630,19510,19388,19266,19144,19020,18899,18781,18672,18574,18489,18414,18345,18284,18230,18182,18141,18103,18068,18035,18005,17978,17955,17940,17930,17923,17921,17921,17917,17917,17917,17917,17917,17917,17917,17917,17917,17926,17926,17926,17926,17926,17926,17929,17929,17929],\"y\":[15176,15218,15256,15292,15325,15351,15371,15386,15395,15395,15395,15395,15395,15379,15359,15329,15289,15236,15171,15091,14998,14892,14773,14644,14498,14336,14161,13972,13778,13574,13369,13159,12948,12742,12540,12349,12170,12009,11860,11726,11606,11500,11410,11331,11264,11208,11165,11133,11109,11094,11082,11082,11072,11072,11072,11072,11072,11072,11072,11072,11072,11078,11078,11078,11078,11078,11078,11089,11089,11089]}]}],\"width\":29700,\"xDPI\":96,\"yDPI\":96}'"


Best Answer

Dear Shreya,


thank you for the update.


In order to use the HMAC key, you may proceed as follows:

  • First, ensure the "Enable Hmac" check box is ticked in the Cloud dashboard of your application
  • To do a "simple REST" request, use a HMAC Generator tool (e.g. https://www.freeformatter.com/hmac-generator.html#ad-output)
  • select the proper digest algorithm: SHA512
  • copy the body of the request in the "Copy-paste the string here" part
  • in the "Secret Key" part, concatene both yout API and HMAC keys.
  • click the "COMPUTE HMAC" button.

=>the computed hmac key shall then be added in the header of the request as the 'hmac' value.


Best regards,


Olivier



Dear Shreya,


Currently, your header appears to not being properly formatted.


Can you please try as follows, it worked on our side:

curl -X POST "https://cloud.myscript.com/api/v4.0/iink/batch"  \
-H "Accept: text/plain,application/json"  \
-H "applicationKey: ***" \
 -H "Content-Type: application/json" \
 -d '{ "xDPI": 96, "yDPI": 96, "width": 815, "height": 1153, "contentType": "Text", "configuration": { "lang":"en_US", "text": { }, "export": { "jiix": { "strokes": false, "text": { "chars": false, "words": true } } } }, 
 "strokeGroups": [ { "strokes":[ ...]}]}'


Best regards,


Olivier



I think there might be some issue with my HMAC. How are you creating the hmac string?

i did not understand how https://developer.myscript.com/support/account/registering-myscript-cloud/#computing-the-hmac-value is working.

would any hmac string creator do?

Answer

Dear Shreya,


thank you for the update.


In order to use the HMAC key, you may proceed as follows:

  • First, ensure the "Enable Hmac" check box is ticked in the Cloud dashboard of your application
  • To do a "simple REST" request, use a HMAC Generator tool (e.g. https://www.freeformatter.com/hmac-generator.html#ad-output)
  • select the proper digest algorithm: SHA512
  • copy the body of the request in the "Copy-paste the string here" part
  • in the "Secret Key" part, concatene both yout API and HMAC keys.
  • click the "COMPUTE HMAC" button.

=>the computed hmac key shall then be added in the header of the request as the 'hmac' value.


Best regards,


Olivier


Thanks! it worked!

  • Support
  • Forums
  • Text
  • swagger script API keeps returning access.not.granted (error code 401)