MapInfo Pro Developers User Group

 View Only

"Missing Authentication Token" as result of an HTTP request.

  • 1.  "Missing Authentication Token" as result of an HTTP request.

    Posted 03-26-2023 12:33

    I have built an application to request HTTPS info written in JavaScript+HTML, and runs OK. Now I am translating it to MapBasic using the HTTP libraries but I get a response. The kernel function in JavaScript is:

    function httpGet(url, key, callback) {
       var xmlHttp = new XMLHttpRequest();'GET', url, true);
       xmlHttp.setRequestHeader('X-Api-Key', key);
       xmlHttp.setRequestHeader('Content-Type', 'application/json');
       xmlHttp.onload = function () {

    in MAPBASIC I  send the request with the function 

    MISendRequest(hFile, strHeaders, Len(strHeaders), strOptional, Len(strOptional), bAuthenticate)

    where strHeaders = "Content-Type: application/json, X-Api-Key: "+s_mykey, strOptional="" and bAuthentica=1, and hFile is the result of the function

    hFile = MIOpenRequestFull(hConnection, nVerb, strObject, strReferer, dwContext, strVersion, dwFlags)

    with nVerb=GET, strReferer="", dwContext=1, strVersion=HTTP/1.1 and dwFlags = INTERNET_FLAG_SECURE and INTERNET_FLAG_EXISTING_CONNECT. These parameters have always worked ok for me before.

    But this time I get "Missing Authentication Token" and the status code is 403 ("forbidden").

    Which is the trick to solve this issue?

    Thank you very much.

    Sergi GR

    Sergi Gamiz-Ribelles
    Knowledge Community Shared Account