I have an applicatoin that gets the birthday of the users threw a form and than it's supposed to write on there wall on there birthday.
Is this possible? even if they visit the app today and there birthday is in 200 days? Because I know the token only lasts 60 days and I want to post with there fb profile.
If I try to post the message on my fan page (where I can get a token that lasts forever) and tag them it doesn't work, because facebook doesn't allow tagging threw the api, you have any suggestions how can I achieve this?
For posting a feed on the user's wall, you can use the APP Access Token instead of the extended user token you are saving.
App Access Token
Facebook removed the offline_access permission a couple of years back:
https://developers.facebook.com/docs/roadmap/completed-changes/offline-access-removal/
"Note: The user must access your application before you're able to get a valid "authorization Code" to be able to make the server-side OAuth call again. Apps will not be able to setup a background/cron job that tries to automatically extend the expiration time, because the "authorization code" is short-lived and will have expired."
Basically you need an Authorization code to get a new token, and you can only get that if the user actively uses your app.
Related
As the title suggests im wondering how i could obtain a never expiring facebook user access token. Which i would need to create a page access token at a later date. I tried using their graph explorer tool but i could only make it go up to 2 months of expiry date and for my use case that wouldnt be ideal.
To shortly explain my use case, on our website im trying to implement a facebook sharing system where each user could share what they wanted i.e posts on their facebook page (we are not using facebook login and the user would just give acces from their own dev tool panel if thats the correct approach). I got this to work BUT only with a acces token that would expire in 2-3months. So a user having to re-authenicate with our service every 2-3 months isnt ideal and wouldnt really work for us. So is there a way i can refresh that token programtically or does the user have to give a new user access token every couple of months.
I have tried following this answer but with no luck Long Lived access token Facebook Page and many similar answers to this. There is also a suggestion that you should contact facebook if you want a never expiring access token which this user suggested Generate permanent access token Facebook API.
Now im wondering if it even is possible do that in 2021 and if there is anything i missed in regards how to generate said tokens or refresh them.
EDIT:
I used the following requests to get the extended access token.
https://graph.facebook.com/oauth/access_token?client_id=<your FB App ID >&client_secret=<your FB App secret>&grant_type=fb_exchange_token&fb_exchange_token=<your short-lived access token>
After i got the token i used
https://graph.facebook.com/me/accounts?access_token=<your long-lived access token>
to get the extended access token.
To get page access token that never expires, take the following steps:
Get user token
Make this token long-lived, e.g. by clicking "Extend access token" at the bottom of the page: https://developers.facebook.com/tools/debug/accesstoken/
Then, use this token to get page access token.
In Access Token Debugger the token will be marked as "Expires: never"
I have a PHP application usign LinkedIn API to show my company updates.
I know that the Access token has a duration of 60 days. And to refresh it I need to are connected to linkeIn and have a current Access token with less than 60 days old.
But my question is, in my application, users don't log in it, I use my own account to get the first access token and call API method with my Access Token.
How can I refresh my own access token to my web application works more than 60 days without get a new token manually? If I don't do anything but my app is still calling the API, the access token will be refreshed automatically?
Thanks a lot!
I am not sure but I think you have to manually login and update the 60 days token.
I have build a similar c#.net app where I save the token and exp.date in a file. I then cache the file for ever.
I cache the result from API for 5min. When cache expires and I make a new request to the API I also check the exp. date of the token.
When it is less then 3 days I send an email to admin to update the token by login in through my special login window where I save the 60 days access token.
LinkedIn's OAuth 2.0 documentation covers how to refresh your access tokens: https://developer.linkedin.com/docs/oauth2#refresh
Note that there is a requirement that the user is logged into linkedin.com in order to refresh their token - so if your app has no user interaction when you attempt to do the refresh, it won't work and the tokens will be expired by LinkedIn.
I've searched a lot and I see that offline_access on fb is deprecated. So, I have a website hat needs to Post a photo at the Client's wall (Post at site and Facebook too), but I want to store the login data (via token or something like that), I read here that I can't store it.
There is another way to post on wall or my client will need to Post manually on his fb?
Edit: My website is in one server, the admin is in another server, I'll make a call from admin server to site in a page that stores login information (if it's possible) and post on his wall a photo.
Thanks
Note: I've searched a lot since yesterday I didn't found anything like that, if you have a similar post with the answer please let me know.
If you have the user's access token you can use that token to perform activities on his behalf.
But the point here is- this token expires in 2 hours. But, you can extend this token upto 60 days. But after that, user needs to visit your app again to get the normal token again and you can then refresh that token to extend its validity again.
You can read Expiration and Extending Tokens section in this doc: Access Tokens
(Just a suggestion) What you can do anytime user visits your app, extend it save on your server. So, the token wont expire until and unless user didn't visited your app for 60 days. And when you are close to 60 days send him some notification.
I have an app that allows users to manage their Facebook Pages. I have done a section on my app where users can put posts on a queue and program them to be sent on the future. For example, a page administrator is going on vacation and prepares some posts to be sent while away.
This is done with a cron task that sends the posts when the scheduled time comes. The problem is that to write on a Page I need a Page Access Token and I can't get that with a App Access Token (or can't find how to do that).
Being a cron task there is no user interaction at all so I can't get neither an User Access Token nor a Page Access Token. The user has previously authorized a Facebook App with manage_pages and publish_stream permissions.
I've tried everything to exchange an App Access Token for a Page Access Token without success.
After struggling my mind and reading (almost) all the documentation on Facebook I came with an idea: maybe I could get the users Access Token when they prepare a post to be sent on the future and save it. The problem here is what would happen if the token expires or is invalidated.
Any help would be appreciated :D
What you are trying to do need offline_access which is deprecated which is now being replaced by Extended Expiry time Access Tokens.
Read : https://developers.facebook.com/roadmap/offline-access-removal/
You can just use the sample codes given on the documentation, and get an extended access token which you can then save to a database to be retrieved when the cron hits the time to fire the post.
Sample : https://developers.facebook.com/docs/howtos/login/server-side-login/
I am working on a simple Facebook App that will allow me to post from my client's website to my client's Facebook Fan Page.
Right now I set the access token with $facebook->setAccessToken( EXTENDED_ACCESS_TOKEN_IN_DB ); after creating my application instance with the PHP SDK. I am using the 60 day long-lived extended access tokens so the client does not have to login to Facebook each time they want to post to the Fan Page.
At some point, the access token will become invalid for any number of reasons.
Under ideal circumstances this would be once every 60 days. At the same time it would be nice if we could continue to publish to the Fan Page from the website through the app until the day arrives that the user de-authorizes the app.
Is there anyway to get a new access token once it has expired without asking the user to login to Facebook?
Is there anyway to get a new access token once it has expired without asking the user to login to Facebook?
No. That’s the whole point of deprecating offline_access – that apps can’t go on “forever” doing stuff in the user’s name.
Maybe you want to get a page access token instead of a user access token? The former ones don’t have a default expiry date.