Cloudboost - Register User Error - cloudboost

I'm using the example from your quickstart section on your website to register a user, problem is, it is throwing back an error. Did I miss something? See below for the error.
Error: Request failed with status code 400 -
https://api.cloudboost.io/user/ohoydfjlnmnf/signup
CB.CloudApp.init('ohoydfjlnmnf', '********-3*9b-4**b-9***-a**b**2**5*1');
//Registration
var user = new CB.CloudUser();
user.set('username', 'NEWUSER');
user.set('password', 'PASSWORD');
user.set('email', 'EMAILADDRESS');
user.signUp({
success: function(user) {
//Registration successfull
console.log(user);
},
error: function(error) {
//Error in user registration.
console.log(error);
}
});

Related

Handling error in ajax request in Select2

I need to detect if user session is gone when expanding Select2 combobox. When that condition occurs, response is redirected to login page.
The Select2 is populated using an ajax call, so I have added this to the "ajax" parameter:
transport: function (params, success, failure) {
var $request = $.ajax(params);
$request.then(success);
$request.fail(function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
});
return $request;
}
The problem is that the error reported is not in XHR format (in order to detect 401 HTTP code) but an error telling "SyntaxError: Unexpected end of JSON input".
When seeing the response using Chrome developer tools, I do see that the response was in XHR format with 401 HTTP code but Select2 transforms it in some way.
Is there a way to solve this?
Regards
Jaime
ajax: {
// ...
error: function (jqXHR, status, error) {
console.log(error + ": " + jqXHR.responseText);
return { results: [] }; // Return dataset to load after error
}
}

How to handle cloudboost errors in Ionic2?

The error I get when the user fails to log in is "Error: Request failed with status code 401". This error is logged here:
static login(username : string, password : string){
return new Promise(resolve =>{
let user = new CB.CloudUser();
user.set('username', username);
user.set('password', password);
user.logIn({
success: function(user) {
console.log("user");
resolve();
},
error: function(error) {
console.log(error);
resolve(error);
}
});
});
}
But what I need is the error that actually says what went wrong e.g. "invalid username" or "User is not authenticated".
How do I get these?
Error: Request failed with status code 401
This error generally means that the login request you made to the server was not authenticated/ you were not authorized to make the login request. This can mean that the CB instance is not properly initialized. Please check the appId and the master/client key you are using to initialize the CB instance.

react-native error RCTJSONStringify() encountered the following error: Invalid type in JSON write (NSURL)

I am trying to use react-native-fbsdk in my react-native app. It was working fine untill yesterday. But, today it gives a weird error stating RCTJSONStringify() encountered the following error: Invalid type in JSON write (NSURL).
RN v0.42.0
Here is my code:
_fbAuth(error, result) {
if (error) {
console.log("error");
alert("login has error: " + result.error);
} else if (result.isCancelled) {
console.log("login cancelled");
alert("login is cancelled.");
} else {
AccessToken.getCurrentAccessToken().then((data) => {
console.log("login success");
console.log(data.accessToken.toString());
let accessToken = data.accessToken;
alert(data.accessToken.toString());
const responseInfoCallback = (error, result) => {
if (error) {
console.log(error);
} else {
console.log(result);
}
}
const infoRequest = new GraphRequest(
'/me',
{
accessToken: accessToken,
parameters: {
fields: {
string: 'email,name,first_name,middle_name,last_name'
}
}
},
responseInfoCallback
);
// Start the graph request.
new GraphRequestManager().addRequest(infoRequest).start();
});
}
}
render() {
console.log("in new render");
return (
<View style={styles.container}>
<LoginButton
publishPermissions={["publish_actions"]}
onLoginFinished={this._fbAuth}
onLogoutFinished={() => alert("logout.")}/>
</View>
);
}
The error information printed in debugger:
I get the above error while calling the graphAPI in the function responseInfoCallback. Any ideas what is happening ?
Update 1:
This error happens only when remote debugger is turned on!! Else it is not happening. But without remote debugger, I cannot proceed with developing the app. Are there any other methods to see log statements of react-native app other than remote debugger ?
Update 2:
The RCTJSONStringify() error happens only behind proxy. And also https fetch calls does not work under proxy. I tested in an open network, it works fine. I guess, it is to add some proxy information to RN app. I think it is related to APP transport security
If you turn the debugger off, you can see the proper error in the XCode console. Access it from Xcode menu View/Debug Area/Activate console, if it's not enabled automatically.

Does Firebase provide access token for consuming Google API's (Contacts, Calender)?

I have this code for accessing Google Contacts API using firebase.
It authenticates the user and returns the access_token but it does not seem to work accessing the Contacts API(I am using AngularFire). Here is the code:
var ref = new Firebase("<<FIREBASE-APP>>");
$scope.click = function() {
ref.authWithOAuthPopup("google", function (error, authData) {
if (error) {
console.log("Login Failed!", error);
} else {
console.log("Authenticated successfully with payload:", authData);
console.log(authData.google.accessToken);
var resource = "https://www.google.com/m8/feeds/contacts/default/full?alt=json&access_token=" + authData.google.accessToken;
$.getJSON(resource,function (response) {
console.log(resource);
});
}
The error received is:
https://www.google.com/m8/feeds/contacts/default/full?alt=json&access_token… 401 (OK)
Here is the format of authData received:
-auth
-provider
-uid
-expires
-google
-accessToken
-displayName
-id
-cacheduserprofile
-provider
-token
-uid

Cordova/Ionic Facebook getLoginStatus not working

I am developing an App in Ionic/Cordova with Login over Facebook. Before showing the "Login-Page" I would like to check if the user is already connected.
The following getLoginStatus check works as expected in the iOS Simulator. When testing on the actual device, the getLoginStatus callback does not get fired.
facebookConnectPlugin.getLoginStatus(
function (response) {
if (response.status == "connected") {
set_tokens(response);
$location.path('/tab/person/me/events');
}
},
function (response) { alert(JSON.stringify(response)) }
);
Already set the Facebook-App to public and verified the App-Id.
Can anybody give a reason for the described behaviour?
I have the following implementation for Facebook login using facebookConnect Plugin.
facebookConnectPlugin.getLoginStatus(
function(response){
if(response.status == "connected"){
//do something, for example share or redirect
}else{
facebookConnectPlugin.login(["basic_info"],
function(success) { /*do something...*/},
function(error) {
//handle error
});
}
}, function(error) {
// handle error
})
}
If you still have errors, try to log the error and success events to see what is happening. This implementations works in a controller.

Resources