Search code examples
ajaxjsonweb-servicesapistormpath

api.stormpath rest json post data for loginAttempts method


am new on stormpath api. i read documents for the create application & User.and i did it successfully.

now, i want to authenticate or validate user using web services.for that my code is

var Result = btoa(String.fromCharCode.apply(null, new Uint8Array(bytes)));


        var postData = { "type": "basic", "value": Result };

        $.ajax({
            type: "POST",
            url: "https://api.stormpath.com/v1/applications/ApplicationID/loginAttempts",
            crossDomain: true,
            contentType: "application/json;charset=UTF-8",
            data: JSON.stringify(postData),
            success: function (response) {

                alert(response);
            },
            error: function (ErrorResponse) {
               alert(ErrorResponse.statusText);
            }


        });

Now, here always i am getting "error" on errorresponse. and when i check on browser console, it's show authoried error.

so, kindly let me know what step i am missing.

also, i download the secure key value file & put on the root. i am calling from my localhost. so, that's why is it not work?


Solution

  • Currently the Stormpath API does not support calls from native clients (such as the browser), but that feature is coming soon! In the meantime I would suggest creating a lightweight server to sits between your front-end application and our API. We have SDKs and sample apps for many languages and frameworks, check out the docs for more info: https://docs.stormpath.com/home/