angular-facebook icon indicating copy to clipboard operation
angular-facebook copied to clipboard

An access token is required to request this resource, OAuthException, code: 104

Open serraventura opened this issue 10 years ago • 8 comments

I'm trying to use the module just to get data from a public Fanpage no authentication needed at all.

Basically, I'm doing a very simple test.

I do the initialization, like below:

.config(function(FacebookProvider, FanPageConfig) { FacebookProvider.setSdkVersion('v2.3'); FacebookProvider.init(FanPageConfig.fanPageId); //myfanpageapp

})

and in my Controller:

Facebook.api('/myfanpageapp', function(response) { $scope.test = response;

});

In my Chrome Dev Tool I can see the request:

https://graph.facebook.com/v2.3/myfanpageapp?callback=FB.__globalCallbacks.f3d42770fc&method=get&pretty=0&sdk=joey

and I'm getting the following error:

{"error":{"message":"An access token is required to request this resource.","type":"OAuthException","code":104}}

If you access the URL straightway you can see the data:

https://graph.facebook.com/myfanpageapp

Is there any setup missing?

serraventura avatar Apr 02 '15 18:04 serraventura

Hi Thiago, as I said by email, it is just a matter of setting it correctly and using calls properly. Be calm. Now, I would like to help but I will ask you an example where we (ngFriends) could help you. Please use jsfiddle or plunker (http://plnkr.co/) to create a working example as you have it now.

Regards, Luis

luiscarlosjayk avatar Apr 02 '15 18:04 luiscarlosjayk

Hey mate,

This is my simple example I'm talking about. http://plnkr.co/edit/v90Uvoa0qZWH4eqtV5Ov?p=preview

I believe it might be some setup missing. If so, I'll contribute on the readme :)

Thanks Thiago

serraventura avatar Apr 02 '15 21:04 serraventura

@serraventura You need to replace fanPageId with a Facebook App ID on this line:

FacebookProvider.init(FanPageConfig.fanPageId); //myfanpageapp

create one here https://developers.facebook.com/apps

geoffliddiard avatar Apr 03 '15 06:04 geoffliddiard

Hi @gliddiard ,

If you have a look on my Plunker you can see I'm using the name of my fanpage. Like this https://graph.facebook.com/myfanpageapp. What I understood from DOCs you don't need to create an APP to get public infos from a Fanpage, you can use the fanpage ID or the name.

Actually I tested with both the name(myfanpageapp) and ID(798758500213688) returns me the same error.

If you access these links straightway you can see the same data https://graph.facebook.com/myfanpageapp https://graph.facebook.com/798758500213688

But now I'm in doubt. Should I create an APP to get infos from a fanpage?

Thanks

serraventura avatar Apr 03 '15 10:04 serraventura

@serraventura to use the Facebook SDK, you need to initialise it with an APP ID e.g:

FacebookProvider.init("YOUR_APP_ID"); 

then you can make API requests to any public endpoint via Facebook.api() method. If all you need to do is read from a public graph endpoint, you don't really need to use this library, you could just use angular's built in $http service

$http.get('http://graph.facebook.com/myfanpageapp').then(function (res){
    console.log(res.data);
});

geoffliddiard avatar Apr 03 '15 10:04 geoffliddiard

I created an APP and tested the ID and I'm actually getting the same error. Even so, I cannot see the relation between the APP and the Fanpage.

How does my APP know which Fanpage it should get the data?

I'm guessing there's no need to create an APP.

If I'm wrong let me know.

thanks

serraventura avatar Apr 03 '15 10:04 serraventura

Ops I did not see your answer. I'll consider it.

So, I should not use this library. I was thinking about it that maybe this library is not supposed to work in this way, only for facebook APPs.

Thanks @gliddiard

serraventura avatar Apr 03 '15 10:04 serraventura

@serraventura , i need the sample code for getting FB page info. I tried so many ways but i couldn't got the result.

ZINGKabilan avatar Feb 14 '16 10:02 ZINGKabilan