Story:
I wrote a Node.JS script that successfully connects to the Facebook API through my facebook app. I can read the data when I give it oauth access_token, I want this script to run on my server every night to store some data. I did a lot of research on both facebook api, oauth, and similar stack overflow issues. I'm looking for an endpoint/search/?type=event&q=query
Problem:
However, Facebook returns 60 days access_tokenthrough the oauth2 registration process, which required me to create a server expressthat simply initiates the oauth2 process, allows the user to log in and get the code, access_tokenand I store it.
I want the script to save data so that my server can provide access to updated data every day. I do not want you to forget to log in to generate a key once every 60 days.
Question:
Is there anyway to get oauth2 access_tokenwithout setting up a server httpor express? More importantly, how do I get access_tokenwithout having to manually start this server every ~ 60 days.
the code:
For the module that I use, are required access_tokenandclient_secret
fs.readFile('./facebookAuthServer/oauth.txt', function read(err, data) {
if (err) {
throw err;
}
fbNode.setAuthorization({token: data, clientSecret: authSettings.clientSecret});
fbNode.fetchItems(displayItems);
});
Is there a way to trick the headers? or can I use a short-term access token and renew it? In any case, to update the 60-day token? Has anyone created an Oauth2 server-side implementation that does not require visiting the FB login more than the first time?