Facebook not giving permission to access users uploaded photos - javascript

Invalid Scopes: user_photos. This message is only shown to developers. Users of your app will ignore these permissions if present. Please read the documentation for valid permissions at: https://developers.facebook.com/docs/facebook-login/permissions
function login( callback ) {
FB.login(function(response) {
if (response.authResponse) {
//console.log('Welcome! Fetching your information.... ');
if (callback) {
callback(response);
}
} else {
console.log('User cancelled login or did not fully authorize.');
}
},{scope: 'user_photos'} );
}

https://developers.facebook.com/docs/facebook-login/permissions/#reference-user_photos
This permission is restricted to a limited set of partners and usage requires prior approval by Facebook.

Related

How to preserve user logged in using Parse JS and Facebook SDK

I'm using Parse Server + Parse JS Sdk to handle user login through Facebook. Everything works fine until I refresh web browser. What data should I store after login process is done? I belive that FB AccessToken is important to keep Facebook Session, but what about Parse Session.
Current code:
login: function (callback) {
console.log('loggin in...')
Parse.FacebookUtils.logIn('user_likes,email', {
success: function (parseUser) {
if (!parseUser.existed()) {
console.log('signed up and logged in!')
} else {
console.log('logged in!')
}
console.log('parse user is: ', parseUser.id)
if (callback) { callback() }
},
error: function (parseUser, error) {
console.log('login cancelled: ', error.message)
}
})
}
You don't need to manually store anything. You can use the parse function:
Parse.User.current()
To see if there is already a user logged-in.
We made this function:
function userAuthenticated(){
if(Parse.User.current() === null){
return false;
}
if(Parse.User.current().authenticated()){
return true;
}
else{
return false
}
}

Getting email from Facebook JS API, issue or feature?

I'm using the following as a reference:
https://developers.facebook.com/docs/facebook-login/web
However, I cannot seem to extract an email. I'm not sure whether this is because the user settings don't allow the email, or that this is an issue with the calls I'm making.
Here is the code that I'm using:
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
var result = JSON.stringify(response);
alert(response.email)
}, {scope: 'public_profile,email,first_name,last_name'});
<fb:login-button data-scope="email" scope="public_profile, email" onlogin="checkLoginState();">
</fb:login-button>
I can login fine, but I get nothing for the email. I don't know if this is a user settings issue or code issue.
There is no scope parameter for FB.api, and you are already defining the scope in the login button. There is also no scope called "first_name" or "last_name", those are just fields in the user table.
Anyway, since v2.4 you have to specifiy the fields in the API endpoint: https://developers.facebook.com/docs/apps/changelog#v2_4
For example:
FB.api('/me', {fields: 'email,first_name,last_name'}, function(response) {
...
});
You can read more about FB.api in the docs: https://developers.facebook.com/docs/javascript/reference/FB.api
Btw, thereĀ“s an article about login with the JS SDK, if you need more information: http://www.devils-heaven.com/facebook-javascript-sdk-login/

FB.login response does not include authResponse

I am creating a Mobile application with facebook Login using the offcial phonegap plugin
https://github.com/phonegap/phonegap-facebook-plugin
The problem is when I authenticate the application it return the response without the authentication response.
FB.login(function(response) {
alert(response.authResponse);
alert("login:"+JSON.stringify(response));
if (response.session) {
alert('logged in');
} else {
alert('not logged in');
}
},
{ scope: "email" });
where the response is {"id":"12345677876","first_name":"xxxxx".........
Therefore "response.authResponse" is always undefined.

How to authorize facebook app with javascript

I created this simple code:
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
alert('connected');// connected
} else if (response.status === 'not_authorized') {
alert('not_authorized');// not_authorized
} else {
alert('not_logged_in');// not_logged_in
login();
}
And here is the login function, but if I use the login() in the not_autorhized section, the window appear and immediately close (automaticaly)
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
} else {
// cancelled
}
});
}
But how to authorize the app in javascript?
here is my full code: http://pastebin.com/Qv9ayb9V
Updated based on your updated information, now it is a shot in the dark...
You have probably already authenticated your app? and are logged in to facebook.
Try going to facebook.com and logging out. (or using FB.logout()) THen log back in to your site. You should be required to login in the popup
Facebook provides step by step guide on their site explaining how to do this.
https://developers.facebook.com/docs/howtos/login/getting-started/
Did you define the login function? It is not provided by facebook:
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
} else {
// cancelled
}
});
}
FB.login takes an additional param with some config options: one is the scope
{scope: 'email,publish_actions'}
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
} else {
// cancelled
}
}, {scope: 'email,publish_actions'});
}

Facebook app with error

I'm not a Facebook App expert. I grabbed this code from the FB website and I modified it to make it work with my app id (it is the only thing I changed. I added a couple of alerts too). Then I tried to use this code from a local webpage (that is: the page is on my desktop but my laptop is connected to the Internet).
Anytime I run this code I get a browser popup showing this error:
"An error occurred with MyAppName. Please try again later."
Can someone tell me what's going on here? It seems the FB.getLoginStatus never gets called too.
Any help is appreciated.
// initialize the library with the API key
FB.init({ appId: 'myAppID',frictionlessRequests:true });
// fetch the status on load
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
// the user is logged in and has authenticated your
// app, and response.authResponse supplies
// the user's ID, a valid access token, a signed
// request, and the time the access token
// and signed request each expire
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
} else if (response.status === 'not_authorized') {
alert("1. not");
// the user is logged in to Facebook,
// but has not authenticated your app
} else {
alert("2. alert");
// the user isn't logged in to Facebook.
}
});
$('#login').bind('click', function() {
FB.login(handleSessionResponse);
});
$('#logout').bind('click', function() {
FB.logout(handleSessionResponse);
});
$('#disconnect').bind('click', function() {
FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
clearDisplay();
});
});
// no user, clear display
function clearDisplay() {
$('#user-info').hide('fast');
}
// handle a session response from any of the auth related calls
function handleSessionResponse(response) {
// if we dont have a session, just hide the user info
alert("entered handleSessionResponse");
if (response.authResponse) {
alert('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
alert('Good to see you, ' + response.name + '.');
});
} else {
alert('User cancelled login or did not fully authorize.');
}
if (!response.session) {
clearDisplay();
return;
}
}
Have you changed the property myAppID to the ID of the Facebook app you are using?
FB.init({ appId: 'myAppID',frictionlessRequests:true });
The myAppID should contain a unique Facebook App ID which you can fetch on the Facebook App page. Maybe you just copied the code without changing this.

Categories

Resources