I want to create simple Google Chrome extention which would display News from Facebook.
News feed can be retrieved by calling this:
https://graph.facebook.com/me/home?access_token=...
But I need access_token.
Could someone give a hint how to define a JavaScript function which would return access_token when given YOUR_APP_ID. This function also should work inside Chrome Extention.
Other examples on the internet did not work, because:
- I don't have a server.
- FB.getLoginStatus does not seem to work.
EDIT1:
I've tried this:
function getAccessToken2(YOUR_APP_ID) {
alert("before FB.init");
FB.init({
appId : YOUR_APP_ID ,
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
alert("before FB.login");
FB.login( function (response) {
alert("response");
if ( response.authResponse ) {
alert("response.authResponse");
var access_token = response.authResponse.access_token;
alert(access_token);
}
} );
}
And I've got:
- alert("before FB.init");
- alert("before FB.login");
Popup opened. It's URL is this. The content is:
API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.
But I've did NOT got:
- alert("response");
- alert(access_token);
- no other JavaScript errors seen in debug mode.
Edit2 The issue here is that I need to authenticate at Facebook like a desktop application. IMHO.