Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
serraventura opened this issue Apr 2, 2015 · 8 comments

Comments

@serraventura
Copy link

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?

@luiscarlosjayk
Copy link
Owner

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

@serraventura
Copy link
Author

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

@geoffliddiard
Copy link

@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

@serraventura
Copy link
Author

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

@geoffliddiard
Copy link

@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);
});

@serraventura
Copy link
Author

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
Copy link
Author

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

@ZINGKabilan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants