How to handle pages of user with fb user access token - facebook-graph-api

I am creating an application which connects to a FB app and allows users to login via FB to my application. When login to application using oauth, it will provide a User Access Token. Can i use that token to get list of pages and page access tokens that created by user using User Access Token?
The ultimate target is this project is accessing/managing pages that created by logged users via our own application.
Please tell me possibility of this thing and let me know if you have any other suggestions.
Thank you.
Regards,
Sahan.

Sure, you simply need the right permissions in your login flow. A good overview is listed here: https://developers.facebook.com/docs/pages/access-tokens
You should have a look at the page access token, because they are required as soon as you work with pages.
BTW, afaik it is not possible to create pages with a Facebook app and according to the Graph API reference only updating page information is possible.

Related

Can I use a FB share dialog with a access token?

The situation
I'm developing a web tool that will be used inside a iPhone/Android app.
Inside the app the User have to log into facebook, with the FB app or a regular fallback.
We discovered that the FB session between the app and the webview was not carried over. (If you logged in on FB in the app, you still had to log in to FB in the webview)
To solve this we made the App send the access token to the webview through a POST.
In the web view I use the Graph API to fetch the users FB ID.
The ID is used in a API that the App and the webview-site uses to share data.
So far so good.
The Problem
We want to use a share dialog on some parts of the webview.
But we don't want to login again (We want to use the Access Token for this as well)
(I cannot do any changes to the App itself so I'm stuck with what I have.
A Access Token)
Tries
1) I have tried to find if it is possible to use a regular Share Dialog with a Access Token. It doesn't seem to work from the documentation.
2) It doesn't work to "login" to FB with a access token from what I can tell. No way to pass the Access Token.
3) I can't create a Share Dialog with FB.ui since that function doesn't take a Access Token.
4) Using the URL Redirection method doesn't work either because you will get a login dialog. (Since I can't pass the Access Token from what I can tell)
5) I can post directly to a users feed with fb.api() and the "publish_actions" permission. With fb.api() I can pass the Access Token to the function. But the user can't control what is being sent. I'm worried that might anger users.
I could build a custom dialog for the user and send what they wrote there. That is a last resort if no other solution is found.
When I tried to test this solution in the Graph API Explorer my FB account accused my app for spamming.. So I'm not sure this is a valid solution.
Conclusion
It seems very difficult to share content with only a Access Token.
Solution nr 5 works but I would rather use a regular share dialog.
I know that it seems impossible according to the documentation but FB are not the best at updating their documentation. So I'm hoping someone can give me a definite answer.
Resources
If I understood correctly I'm only allowed to share 2 links, since I don't have enough reputation.
https://developers.facebook.com/docs/plugins/share-button
https://developers.facebook.com/docs/javascript/reference/
you can use this.
https://www.facebook.com/dialog/share?
app_id=xxxxxxxxxx&display=popup
&href=http://google.com
&access_token=<user access token>
check your app access token first at
graph.facebook.com/debug_token?
input_token={token-to-inspect}
&access_token={app-token-or-admin-token}
check that your app has access to user public-profile
graph.facebook.com/debug_token?
input_token=
&access_token=

Request additional permissions only for specific users in Meteor

I have an application allowing users to sign in using their Facebook and Twitter accounts. I only need a very basic information like their email address and full name. Everything works fine and as planned.
Accounts.ui.config({
requestPermissions: {
facebook: ['email'],
github: ['user:email']
}
});
But, now I need to implement a feature posting to a Facebook page and Twitter on behalf of the admin users only. So, I need to get additional permissions from specific users only.
Admin users are eligible to manage our page at Facebook. The app needs to request additional permissions to be able to post to the page. I wan't to keep those basic permissions for regular users.
How can I accomplish that?
One way you can do is,
If you know that logged in user is Admin, put the re-authenticate button in user-dashboard (or somewhere which makes sense) that will do authentication user of user for whatever permissions as required by application.
This will basically do, oauth with social service like usual and upon completion you will get aceess code and against this code get the re-newed access token from social service. (This is normal , how you basically do the oauth manually) Now, use this access token to post to social services.
For this, you will need to use node modules such as for facebook -fb_graph , for twitter- twiiter
Hope this helps

Graph API - as user?

I am trying to get to grips with the Graph API. Is i,t correctly understood that if I want to ask for my own, say friends, through code, I should
register my application and get an app access token
Login with my own credentials and get an user access token?
I find it difficult to grasp the concepts from the documentation.
The flow should go like :
User adds the app and gives the permissions.
Which returns the access_token (user access token) which is used to query datas.
Generally speaking, You ask for permissions, and you get a key which can open the locked contents. That is the access_token.
Difference between App Access_token and User access_token :
App access_token is needed when you do something as the app. Like getting the insights for the app, or working with subscriptions, so and so.
User access_token is needed when you want to act as the user who have the app added in their account.
With reference to your question, You clearly doesnt need App access_token.
You need to do both.
Registering your application tells Facebook where those requests are coming from. They monitor what requests your app is making to police apps that violate your terms.
Once you have that app, you personally authenticate it to get information from or post information to Facebook on your behalf. The app must ask for specific permissions and you have to grant these for it to work.

facebook graph api: how to use me correctly?

i am trying to use /me/likes/pageID the same way i used pages.isFan (REST API).
But it always uses the user/page as me for which i created the access token and not the current active user.
can't get my head around this one, any help is appreciated!
thanks
[from comments] but do i really need to create an application to "just" check if the user is fan of my own page? and even ask his authorization?
Yes, you will need an app in any case.
If you run your app as a canvas or page tab app inside of Facebook, then you get the info if the current user liked the very Facebook fan page the app is running in(!) directly from the signed_request parameter.
If you want to query this infor for other pages, and/or your app is running outside of Facebook, then you have to have the user connect to your app and ask permission to read his likes first, before you can get this info.
For information on the latter case, see https://developers.facebook.com/docs/authentication/, https://developers.facebook.com/docs/authentication/permissions/#user_friends_perms, https://developers.facebook.com/docs/reference/api/user/#likes
It is easy: With the new Graph API, the owner of the access token is me. You can see this by pasting an access token into the debugger.
You should be authenticating your user and gaining an access token in their name each time they visit your site. Then use only this access token when you make your query.
This process is easiest if you use one of the Facebook SDKs.

Facebook Integration Static access token

I'm trying to use the facebook API on the backend of a website. Essentially, I want to be able to create events using a Djano app and have it create the corresponding facebook events.
The organization I am creating events for already have a facebook page. I only am concerned with posting events on that organization's page. I am the admin for the organization so I know all the login info.
What I am am trying to figure out is how I can setup the access token such thatit just works for the organization without any need to login to the facebook app. I was thinking that setting a static access token would do the trick, but I cannot find anyway to do it.
So, what is the standard way to create a facebook app that only interfaces with one predefined user?
Im not entirely sure what you're trying to do. However the static access token has now been deprecated. Do you want to: create an event for the person using the page, or for the company's page/profile?
Hope I can help