Can't login via facebook API - api

I'm using the Javascript SDK to allow the user to login to facebook, retrieve their friends profile pictures, and then finally post a message on the logged in users wall. Problem is I keep getting an error, "Error while loading page from Pencils of Promise," when the user has to authorize the application.
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({appId: '154058871279888', status: true, cookie: true,
xfbml: true});
console.log(FB.getLoginStatus());
$('div.voice-btn:eq(0)').click(function() {
FB.login(function(response) {
if(response.session) {
FB.api('/me', function(data) {
console.log(data);
});
donateVoiceSlider();
}
});
});
$('#voice-step-2-btn').click(function() {
var body = 'Test Facebook post';
FB.api('/me/feed', 'post', { body: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response);
}
});
});
// Donate Voice Content Slider
function donateVoiceSlider() {
var $ul = $('#donatevoice');
var cur_left = parseInt($ul.css('left'));
var li_width = 980;
$ul.animate( {'left': cur_left-li_width+'px'} );
}
</script>
Please help!

My friend who had created the application did NOT set the site URL. After doing that, everything ran smoothly.

Related

facebook login failed using javascript sdk

I'm using Facebook login .. but recently i got an error while fetching data for signin / signUp
this's my code
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else if (response.status === 'not_authorized') {
fbLogin();
// The person is not logged into your app or we are unable to tell.
document.getElementById('status').innerHTML = 'Please log ' +'into this app.';
}
else {
// The person is not logged into your app or we are unable to tell.
document.getElementById('status').innerHTML = 'Please log ' +'into this app.';
}
}
function checkLoginState() {
FB.getLoginStatus(function (response) {
statusChangeCallback(response);
});
}
function fbLogin() {
debugger;
FB.login(function (response) {
//if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me/?fields=picture,name,email', function (response) {
console.log(response);
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
//} else {
// console.log('User cancelled login or did not fully authorize.');
//}
}, { auth_type: 'reauthenticate', auth_nonce: '{random-nonce}' });
}
window.fbAsyncInit = function () {
FB.init({
appId: '393788184007786',
cookie: true, // enable cookies to allow the server to access
// the session
xfbml: true, // parse social plugins on this page
version: 'v3.2' // The Graph API version to use for the call
});
};
// Load the SDK asynchronously
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', { fields: 'name,email' }, function (response) {
var info = response.id + '#' + response.name + '#' + response.email;
console.log('Successful login for: ' + info);
});
}
</script>
and this is button included in html for signin
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
and response from getLoginState() is:
{ authResponse: undefined, status: "not_authorized" }
and this's error shown enter image description here
i'm getting an message in facebook app said " We've restricted this app for violating the Facebook Platform Policies"
any suggestions for solving this issue?!!
The brackets are just placeholders, you have to remove them:
FB.init({
appId: '393788184007786',
cookie: true,
xfbml: true,
version: 'v3.2'
});

Skype Web API sing in issues using login and password

I have issue with signing into Skype account using login and password. I use code from Skype Web SDK docs:
<script>
// Call the application object
var config = {
apiKey: 'a42fcebd-5b43-4b89-a065-74450fb91255', // SDK
apiKeyCC: '9c967f6b-a846-4df2-b43d-5167e47d81e1' // SDK+UI
};
var Application;
Skype.initialize({ apiKey: config.apiKey }, function (api) {
window.skypeWebApp = new api.application();
window.skypeWebApp.signInManager.signIn({
username: "test#yandex.ru",
password: "12345678"
}).then(function () {
console.log('Signed in successfully.');
}, function (error) {
console.log('Failed to sign in.');
}).then(reset);
}, function (err) {
console.log(err);
alert('Cannot load the SDK.');
});
The POST request is sent, but API returns nothing. Can anybody advice?

Google api revoke token issue

I've created an application using google drive API to list and manage all my drive files.
Everything goes fine, except the log out part. I've searched for two days for a solution without a result.
The following is code related to login and works fine:
function checkAuth() {
gapi.auth.authorize(
{
'client_id': CLIENT_ID,
'scope': SCOPES.join(' '),
'immediate': true,
'authuser': '-1'
}, handleAuthResult);
}
function handleAuthResult(authResult) {
var authorizeDiv = document.getElementById('authorize-div');
if (authResult && !authResult.error) {
// Hide auth UI, then load client library.
authorizeDiv.style.display = 'none';
loadDriveApi();
} else {
authorizeDiv.style.display = 'inline';
}
}
function handleAuthClick(event) {
gapi.auth.authorize(
{client_id: CLIENT_ID, scope: SCOPES, immediate: false},
handleAuthResult);
return false;
}
function loadDriveApi() {
gapi.client.load('drive', 'v2', listFiles);
}
I'm able to login and work with files, but when I try to logout with following I get No 'Access-Control-Allow-Origin' error
$(document).on('click', '.logout', function(){
var token = gapi.auth.getToken();
if (token) {
var accessToken = gapi.auth.getToken().access_token;
if (accessToken) {
var revokeToken = 'https://accounts.google.com/o/oauth2/revoke?token=' + accessToken;
jQuery.getJSON(revokeToken).success(function(data) {
console.log(data);
}).error(function(message) {
console.error('error' + message);
}).complete(function() {
console.log('completed!');
});
}
}
gapi.auth.setToken(null);
gapi.auth.signOut();
});
In Google Developers Console I've regitred my website to Authorized JavaScript origins.
Thanks

Opening a page after login doesn't work

Using PhantomJs & CasperJs, I would like to :
Get the login page of a website
Fill the form and send it
Once i'm connected, get the content of an other page.
I'm stuck at step 3.
I absolutely do not understand how to get another page after the first one.
I read the documentation, many forums, etc ...
Here's my code :
(I did replace login/password and links).
var casper = require('casper').create({
clientScripts: ["lib/jquery-2.1.1.min.js"]
});
casper.start("https://my_website/login");
casper.waitForSelector('#username', function() {
this.fill('form#fm1', {
'username': "...",
'password': '...'
}, true);
});
casper.then(function() {
//this.echo('Title : ' + this.getTitle());
//this.echo('Title : ' + this.page.content);
// if the page contains the word "Connected",
// the connexion is successful
if (this.page.content.indexOf("Connected") > -1) {
console.log("Connected");
}
});
casper.thenOpen('https://my_website.com/myplanning.jsp', function(response) {
// HERE'S THE PROBLEM !!!!!!!!
console.log(this.getPageContent());
});
casper.waitForSelector('#inner0', function() {
// HERE'S AN OTHER PROBLEM !!!!!!!!
console.log('Great !');
});
casper.run(function() {
this.exit();
});
How can I get the content of "https://my_website.com/myplanning.jsp"?

unknown error creating user with firebase

I am receiving a CORS error from my browser while trying to implement a simple login authentication (email/password) with firebase.
I checked the security rules and it is set to
{
"rules": {
".read": true,
".write": true
}
}
Here's a summary of my code from the example.
<script src="https://cdn.firebase.com/js/client/1.0.15/firebase.js"></script>
<script type='text/javascript' src='https://cdn.firebase.com/js/simple-login/1.5.0/firebase-simple-login.js'> </script>
var myRootRef = new Firebase('https://vivid-fire-myserver.firebaseio.com/');
var authClient = new FirebaseSimpleLogin(myRootRef, function(error, user) {
if (error) {
alert(error);
return;
}
if (user) {
alert('user already logged in');
} else {
alert('user logged out');
}
});
$("#registerButton").on("click", function() {
var email = $("#email").val();
var password = $("#password").val();
authClient.createUser(email, password, function(error, user) {
if (!error) {
alert('registered successfully');
} else {
alert(error);
}
});
});
It appears that the problem is a result of submitting my form, which causes the page to reload. As confirmed with Rob, "the reload is taking place before the HTTP OPTIONS request to the server checking the CORS configuration is able to complete.
A work around is to prevent the form from reloading upon submission. I did this by returning false in my html form and my jquery scripts.
<form class="m-t" role="form" onSubmit="return goLogin()">
..........
function goLogin() {
$("#loginButton").click(function() {
......
)};
return false;
}