Does Facebook re-authentication needed? - facebook

I got this message on last thursday.
Recent updates in our app permission policies applied a 90-day expiration to user permissions (permissions pertaining to a user's profile info such as posts, photos, gender, age range).
Effective immediately, this now applies to {my-app}
I have read https://developers.facebook.com/docs/facebook-login/auth-vs-data, and tried to check what happen when after data_access_expires_at time. I wanted to know how API responses change.
However, I found no documents of neither consequence for being out-dated nor way of make access token be out-dated.
I do have procedure for re-gaining access token when an access token is invalid. But does this procedure covers in the case of re-authentication needed?

Facebook does not offer 'reauthorize' but you can build it on your own. Facebook also does not offer a programmatic way to extend tokens. What they do say however if users that authenticate your app remain active with your app - their tokens will never expire. If they are not active with your app - access only lasts 90 days.
What you need to do is to place Facebook's login script on your pages. This basically establishes the 'activity":
<script>
window.fbAsyncInit = function() {
FB.Event.subscribe('auth.statusChange', function(response) {
// don't have to do anything actually
});
FB.init({
appId : '${facebookAppId}',
autoLogAppEvents : true,
status : true, // check login status
xfbml : true,
version : 'v3.2'
});
};
(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'));
</script>

Related

Facebook App Test Users - Not working with FB.UI()

I'm trying a simple Share dialogue, invoked via Javascript a website page. I can load the SDK fine:
window.fbAsyncInit = function() {
FB.init({
appId : '{My-App-ID}',
xfbml : true,
version : 'v2.0'
});
};
(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 = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
And my javascript function is taken straight from the FB Docs:
FB.ui(
{
method: 'share',
href: 'https://developers.facebook.com/docs/'
}, function(response){});
The issue is testing. I've created a Test App within my main app for this purpose. My Personal Facebook account is an administrator for this App. When logged into my personal account I can invoke the share dialogue and it works fine.
However when I create a 'Test User' from the Roles -> Test Users section on the App Dashboard and log in as them, I get the following error when trying to invoke the share dialogue:
Sorry, this feature isn't available right now: An error occurred while
processing this request. Please try again later.
Very frustrating as I want to test using a test account. Any clues as to why this isn't working? Many thanks.

xxx shared a link via Widget Share Log App

I've created a Facebook App and am using the FB developer tools to share content on a site.
However, when a link is shared it is titled "xxx shared a link via Widget Share Log App". I've seen other sites change this to read something like "xxx shared a link via Irrawaddynews" and I wondered if it was possible to do the same here.
BTW, I'm initiating the Facebook SDK with the code below (as per the instructions here: "shared a link via Widget Share Log App." - but this didn't solve my problem).
window.fbAsyncInit = function() {
FB.init({
appId : '{MY_APP_ID}',
status : true,
xfbml : true
});
};
(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 = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
In your App ID settings on Facebook, there are a few fields you have to update. We wrote pretty detailed setup instructions for doing this in conjunction with our own share software, but there's a general section beneath that for setting up the Facebook app:
https://naytev.zendesk.com/hc/en-us/articles/202777178-Link-Naytev-to-Your-Facebook-App
#userfuser - you actually don't need their validation, you simply need to make the app active. The process has a pretty terrible UX, and missing fields like "support email" will cause you to not be able to activate without a helpful error message.

Application Error while loading the facebook SDK

Code on my web page:
<body class="popup">
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : '476947702378530', // App ID from the app dashboard
channelUrl : '//www.majorforms.com/fb_channel.php?_lang_id=1',// Channel file for x-domain comms
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
};
// 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 = "//connect.facebook.net/en/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
After loading that page with a browser, I get this error in firebug console:
Application Error: There was a problem getting data for the application you requested. The application may not be valid, or there may be a temporary glitch. Please try again later.
I don't really understand. I do not have a real app, I just used the identifier of a facebook (company) account. I do not want to create a new facebook app, I just want to use credentials of a specific facebook account. How do I do that?
I'm not hundred percent sure but you need to create an app to use the facebook sdk because in the FB.init method it obviously asks for the Facebook App Id.
Creating a Facebook App doesn't necessarily mean that you actually have an app on facebook, the app configuration screen on Facebook Developers page has a specific section for "Website With Facebook Login" , so I think thats the way you should go.
I found I was getting this error when testing my application because I was signed into Facebook as a test account user. When I tried to access the live environment it would generate that error as it was already authenticated to the developer user. The error message is kind of generic and doesn't really spell out the issue in black and white.

Facebook auto login - notify user

I am allowing my users to login to my web-app using their Facebook account.
A user is auto-logged in to my website through Facebook if -
They are registered to my site using Facebook
They haven't logged out of my site and ended their session
They are currently signed into Facebook
This is fine, except, there is a pause between the user accessing the homepage and being taken to their dashboard whilst Facebook checks whether they have logged in. Is there a way to show a sort of pre-loader that says "Signing in with Facebook" whilst the transition is made?
I am using the following Facebook javascript -
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxx',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.Event.subscribe('auth.login', function() {
FB.api('/me', function(response) {
window.location='mysite/fb_signin/';
});
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
Thank you.
With the facebook api you are able to check if the user is connected or not before doing to call to FB.api (that is what taking time).
http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/
This should help
I agree with Marc that you can use the getLoginStatus() to help you determine what they are before you send them to one place or another. However, you said something was slow. So that led me to look at your code, and it appears you're missing the channelUrl in your FB.init() call (see https://developers.facebook.com/docs/reference/javascript/ for more information). without the channelUrl user interaction with the Javascript SDK functions will be sluggish and slow.

FB.Auth.setAuthResponse only compatible with OAuth2 issue

Loading my facebook page in a tab shows following error:
FB.Auth.setAuthResponse only compatible with OAuth2.
I use oauth parameter like this:
FB.init({
appId: fbAppId,
status: true,
cookie: true,
xfbml: false,
oauth: true
});
Am I doing something wrong ?
remove the parameters from your JDK including:
script src="http://connect.facebook.net/en_US/all.js"
Log in to the Facebook account that is in charge of the App.
Go to https://developers.facebook.com/apps/ and click on the App in question.
In the left menu, under Settings, click Advanced and look at the settings in the Migrations section.
I encountered this issue on a test environment of mine, and switched the "Encrypted Access Token" setting to 'Enabled' and it seems to resolve the issue for me. I did all this code work for the migration but had NO IDEA that I had to go into the App and mess with settings.
HTH
Some Facebook social plugins(the ones that require actually inserting JavaScript) have their own authentication scheme. The newly implemented Add To Timeline button is one example of a social plugin that will cause this error to appear in your JS console. Try removing social plugins and see if the error persists. If they disappear, your only real option is to switch to XFBML.
when using outh 2 add oauth=1 to provided js function for social plugins
<script>(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 = "//connect.facebook.net/tr_TR/all.js#**oauth=1**&xfbml=1&appId=164442023647373";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
i had this error when using
ow.fbAsyncInit = function() {
FB.init({
appId : '<s:property value="app_id" />',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true
});
Old variables i used:
response.session.access_token
response.session.uid
New variables helped:
response.authResponse.accessToken
response.authResponse.userId