Using javascript Parse.com and keep getting 401 unauthorized

I am doing the initialization as I should with the correct keys, etc. Even when you do it directly in a function that later uses Parse.Cloud.run, I still get 401 unauthorized access.

Is there a way to check if the initialization works correctly? Does it return any answer? error? if so, how do I start to see the answer? initialization is currently simple:

Parse.initialize("appid", "javascript key"); (with the correct keys of course). 

then I call the cloud function:

 Parse.Cloud.run('testfunction', aUserObj, { success: function(result) { supersonic.ui.dialog.alert(result); }, error: function(error) { supersonic.ui.dialog.alert(error); } }); 

and error 401 is unauthorized (which I also see in the javascript console as POST api.parse.com ..... 401 is unauthorized).

btw - using curl and rest api key I can make it work without problems, so this is not an actual permission issue, as far as I can tell.

Thanks.

+6
source share
1 answer

Are you right @nopro

The problem is the parameter format, which causes the entire request to omit the application key and javascript, which leads to error 401.

thanks

I tried to call the function as follows:

  Parse.Cloud.run('sendMessage', message, { success: function(success) { $scope.isLoading = false; }, error: function(error) { $scope.isLoading = false; } }); 

but I had to do it as follows:

  Parse.Cloud.run('sendMessage', {"message":message.id}, { success: function(success) { $scope.isLoading = false; }, error: function(error) { $scope.isLoading = false; } }); 
0
source

Source: https://habr.com/ru/post/979231/


All Articles