I just started to build a web app, and for some reason I have to use CloudKit and its database for my backend.
I tried a really stupid database query and intended to see the results at frontend. Here is my code :
CloudKit.configure({
containers: [{
containerIdentifier: my identifier,
apiToken: my api token,
environment: 'development'
}]
});
var container = CloudKit.getDefaultContainer();
var DB = container.publicCloudDatabase;
var query = {recordType : 'Request'};
DB.performQuery(query).then(function(response){
if (response.hasErrors) {
throw response.errors[0];
} else {
console.log(response);
}
});
However, I keep getting this authentication_failed error :
cloudkit.js:3 Uncaught (in promise) t {_ckErrorCode: "AUTHENTICATION_FAILED", _uuid: "4ef8ba12-eb00-408f-9a1c-6e8b4de84ec8", _reason: "no auth method found", _serverErrorCode: "AUTHENTICATION_FAILED", _extensionErrorCode: undefined…}
I tried to fetch a record with the same code, and it works fine.
So is the error caused by unlogged in users? If so, Is there any configurations in CloudKit Dashboard to allow users from certain URL to query the database without logging in?
Thanks!
Check the containerIdentifier value. I had a similar issue when I used the identifier name of the API Token instead of the generated iCloud identifier from the app name. You can also verify your token with the link Test with CloudKit Catalog
Related
I am trying to use the searchKitManager inside react-admin I provided the parameters etc according to the docs but when I run the code it throws errors. Here is how the code works
React Admin is running on http://localhost:3000
Golang backend is running on http://localhost:3006
ElasticSearch is running on http://localhost:9200
When data is inserted in mysql database using golang code it is also inserted in elasticsearch later on in one of my display component I call the above searchkitManager as follows
let apiUrl= 'http://localhost:9200/donate' // what link should I pass, url to elasticsearch or url to my backend
const searchkit = new SearchkitManager('/', {
searchUrlPath: `${apiUrl}/_search`,
});
This code will throw 404 Not Found or 400 Bad Request error but the API works in postman
if I change the above link to
let apiUrl= 'http://localhost:9200/donate' // what link should I pass, url to elasticsearch or url to my backend
const searchkit = new SearchkitManager('/', {
searchUrlPath: `${apiUrl}/_doc/`,
});
I am not getting anything at all sometimes it no error in console and sometimes 400 Bad Request or 405 Post Not Allowed
One last thing the link I am providing as for searchUrlPath should be like that or not? or should I pass the apiUrl in place of /? I tried that as well but just to make sure.
Any kind of help will be really appreciated.
Try doing this:
const elasticSearchUrl = 'http://localhost:9200/<your_index>';
const searchkit = new SearchkitManager(elasticSearchUrl );
i'm newbie in angular js, have created a project in angular js and want to maintain log on server for all the issues occuring at the client side.
Gone through various blogs and found few suggestions for applying stack js but couldn't understand the implementation for same.
Please suggest if it is possible to log all the errors in project from one single point of client side, at the server through factory or service method using angular js.
This is possibly by overriding angulars built in $exceptionHandler. Below is the snippet of code from my own app that logs any failures to the backend, but also prints them into the console, in case the backend logging fails. As my javascript is minified, I use StackTrace to turn this back into an un-minified stack trace, and send that to my backend.
function exceptionLoggingService($injector) {
function error(exception, cause) {
// preserve the default behaviour which will log the error
// to the console, and allow the application to continue running.
var $log = $injector.get('$log');
var $window = $injector.get('$window');
$log.error.apply($log, arguments);
var errorMessage = exception.toString();
StackTrace.fromError(exception).then(function (arrayStack) {
var exceptionData = angular.toJson({
errorUrl: $window.location.href,
errorMessage: errorMessage,
stackTrace: arrayStack,
cause: ( cause || "" )
});
// now post this exceptionData to your backend
}).catch(function (backendLoggingError) {
$log.warn("Error logging failure.");
$log.log(backendLoggingError);
});
}
return(error);
}
angular.module('dashboard-ui').factory('$exceptionHandler', ['$injector', exceptionLoggingService])
I am trying to run the IBM Watson's Tradeoff Analytics widget to show the trade-off analytics graph in a webpage. The Tradeoff Analytics API is starting properly but when I submit the problem to the show the graph, I get some undefined error.
Here is the sample code that I am using the run the Tradeoff Analytics Widget.
function errorHandler(payload){
alert(payload.errorMessage);
}
function onShowCompleteCB(payload){
alert('show Tradeoff graph complete');
}
function onStartCB(payload){
alert('sending trade-off problem');
var problem = <problem-json>;
taClient.show(problem, onShowCompleteCB);
}
var options = {
dilemmaServiceUrl : <tradeoff-service-url>,
username : <username>,
password : <password>
};
var taClient = new TradeoffAnalytics(options , document.getElementById('watson_widget'));
var s = taClient.subscribe('afterError', errorHandler);
taClient.start(onStartCB);
I also noticed from javascript debugger that HTTP response to the last request returned the reponse header WWW-Authenticate:Basic realm="IBM Watson Gateway Log-in". Moreover I get the following error in javascript console XMLHttpRequest cannot load . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '' is therefore not allowed access. The response had HTTP status code 401.
Can somebody help me out with what might be going wrong here?
PS: I have cross checked my username and password and they seem to be working fine through REST based API invocation.
Based on your code, you are trying to use the client widget. You need to have a proxy app that will receive the request and use your username and password.
On your client side you will need something like:
HTML:
<div id='DIV_ID'></div>
JS:
taClient = new TA.TradeoffAnalytics({
customCssUrl: 'https://ta-cdn.mybluemix.net/v1/modmt/styles/watson.css',
dilemmaServiceUrl: '/proxy',
profile: 'basic'
}, 'DIV_ID');
taClient.subscribe('afterError', function onError(){ /* on error */});
taClient.start(function onLoad(){ /* on load */});
}
Server side(nodejs):
var tradeoffAnalytics = watson.tradeoff_analytics({
version: 'v1',
username: '<username>',
password: '<password>'
});
app.post('/proxy', function(req, res) {
tradeoffAnalytics.dilemmas(req.body, function(err, dilemmas) {
if (err)
return res.status(err.code || 500).json(err.error || 'Error processing the request');
else
return res.json(dilemmas);
});
});
Above you will find an example of how to implement the proxy using express and the watson-developer-cloud npm module.
There is a full sample you can look in github
I'm getting a 403 when trying to update a user's profile using meteor-angular. Unfortunately, it's not very descriptive -- the complete error is:
{
details: undefined
error: 403
errorType: "Meteor.Error"
message: "Access denied [403]"
reason: "Access denied"
}
I'm under the impression that I don't need to add anything to the server side, but I added to try to get some visibility into what the actual update request looked like.
Meteor.users.deny {
update: (userId, user, fields, modifier) ->
console.log("meteor deny!")
console.log(userId, user._id)
console.log(fields, modifier)
false
}
Meteor.users.allow {
update: (userId, user, fields, modifier) ->
console.log("allow", arguments)
true
}
For debugging. In the logs, I see
I20150707-22:14:22.955(-6)? meteor deny!
I20150707-22:14:22.956(-6)? Hk83p9hieEBYHhzo6 Hk83p9hieEBYHhzo6
I20150707-22:14:22.956(-6)? [ 'profile' ] { '$set': { 'profile.name': 'ben', 'profile.gender': 'male' } }
Which is exactly what I would expect to see and appears to be what is required when looking at the docs -- i.e. a user is editing their own profile and the $set is using dot notation. I'm triggering the update from the client, basically using pretty plain angular. The interesting bits are
....
$scope.user = $meteor.object $meteor.getCollectionByName("users"), $stateParams.userId
$scope.save = () ->
if $scope.form.$valid
$scope.user.save({ 'profile.name': $scope.user.profile.name, 'profile.gender': $scope.user.profile.gender}).then(
(numberOfDocs) ->
console.log 'save successful, docs affected ', numberOfDocs
(error) ->
console.log 'save error ', error
)
I'm sort of at a loss for what to try next. My packages are
meteor-platform
urigo:angular
angularui:angular-ui-router
coffeescript
mquandalle:stylus
civilframe:angular-jade
twbs:bootstrap
angularui:angular-ui-bootstrap
mquandalle:bower
tmeasday:publish-counts
aldeed:collection2
angularutils:pagination
accounts-ui
okland:accounts-phone
accounts-base
Not a full answer, but to fix your problem immediately, just create a method that updates a users profile server side. Just check that a user is only trying to edit his own profile.
I am currently writing an angular, express, mongoose(monogodb) app and there is this strange behavior I am running into.
I want to send a mongoose query to the server side so in the client side I write the query as so
var query = {
'_id' : {'$in' : ['1958929ef']}
};
This gets passed into express.js however, when I console.log it the '$in' param is not there.
I get...
var query = {
'_id' : {}
}
When I change '$in' to just 'in' i can see there is no problem.
Why does this happen? Is it because of sanitize? (i removed the sanitize module from angular and the issue still occurs)