How can I login to Facebook from my background job? - facebook

I want to regularly post updates to my company's Facebook page using a timer task. In order to post to a facebook page I need to obtain a user (page) access token. In order to obtain a user access token I need to login to Facebook on behalf of a user.
How can I login to Facebook programmatically with some user's email and password from a background job without clicking on any UI?

You cannot programmatically get an user access token through Facebook Graph API. User access token could only be retrieved by login flow.
In your situation, you can consider using an extended (long-lived) access token.

Related

How can you get an access token for facebook using facebook login in asp.net identity?

If you use Facebook login in an asp.net app, how would you go about getting the profile picture of a user?
It seems to me, from what I have gathered (reading)1, that we need a user access token in order to get it - but when we have the user log in with facebook, we do not receive any kind of access token.
Is there a way to get the profile image just from the data/access you get when using facebook login - and how?

Facebook long lived Page Access Token

I am administrator of facebook page which DOES NOT have a classic facebook account assigned. So I am not able to create any facebook application as you can see in Picture 1. How can I obtain long lived (never expiring) page access token, which I need to use Graph API? I need to post messages to the facebook page from my server.
Thanks for advice
You do need a User account that is admin of the Facebook Page in order to get a Page Token. Without a User account, it is not possible.
Here´s what you need to do:
Authorize the User account in the App - which means, get a User Access Token
Extend the User Token
Get an Extended Page Token with /me/accounts or /[page-id]?fields=access_token
Some Links for more information:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/
http://www.devils-heaven.com/extended-page-access-tokens-curl/

Posting to a Facebook Page Wall from a Web Server

I've been reading documentation and Stack Overflow link all morning, but I'm just not understanding the correct process to authorize a web server to post to a Facebook page wall.
What I'm not clear on is why I have to post to Facebook as a Facebook User, using an access_token, meaning that this user has to log into Facebook manually to authorize my app.
I'm not trying to authorize a User, nor any of my visitors to do anything with their accounts, so I don't need any permissions from them. Instead, I'm trying to authorize my Web Server to post updates to its wall as a specific Page.
Why do I have to use a user access_token to do this? I'm not attempting to impersonate the user, I'm trying to post to the page as the page...
Is it possible to authorize a user and get their access token without having to create a login page on the Web Server? I don't want to have to require the user to login to make this work, I thought that was the point of having an app ID and Secret?
I guess my question is this: Is it not possible to allow a web server to post to a Facebook page wall as that page, without having to present a login dialog to a specific user? If it is possible, what is the correct workflow to set this up?
In order to post to a Page as a Page, you have to use a Page Access Token. You get that with a User Access Token, and you can extend it so it will stay valid forever.
Steps:
Request a User Access Token with the manage_pages permission (valid for up to 2 hours)
Extend the User Access Token (valid for up to 60 days)
Get the Extended Page Access Token for your Page with the User Session
Store and User The Page Access Token in the publish call
It may sound a bit complicated, but there are many tutorials for this and you don´t actually need to program it, you can just use the Graph API Explorer.
Here are some Links about the Access Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/ (see "Extended Page Access Token" for a step by step tutorial)

How to create a Facebook user access token programmatically?

Is there a possibility to get a Facebook user access token, given that I have the user's credentials?
The background is that I am writing a console application which shall act on the user's behalf, and as it's a console application, of course I can not do the OAuth dance.
Is there a request I can make, such as
GET https://graph.facebook.com/getUserAccessToken?login=foo&password=bar
?

Use Facebook app access_token to get age-restricted Page data through Graph API?

I have a Facebook application that users can add to their Facebook business Page(s) as a Page Tab app. It doesn't require any extended permissions for the user. I'm wondering if it's possible to use my app access_token and make calls against the Facebook Graph API to retrieve information about age-restricted Pages?
No, if a page is restricted demographically (e.g. for alcohol) you MUST use a user access token from a user who meets those restrictions, or a Page access token for the page itself.
An app access token will not work for such an API call
If the owner of that access token can view the data on facebook you can get any data using that access token not mater if its block for the others .