I want to make an application to fetch data from my Facebook page and display it in my application.
I tried using the Facebook API Explorer, it work fine but it expires after around 1 hour.
So, I need another way to get access to all my post like text, image and videos without expire data and anyone download my app can show my post without login to Facebook or any authentication.
Non-expiring Page Access Token are seemingly no longer possible with Graph API v2.0. If you have a v1.0 App, you could use the way described at Facebook non-expiring access token to get a non-expiring Page Access Token.
Related
I'm using the LinkedIn Javascript SDK on my website in order to allow users to register and log in via Linked In.
I want to achieve this without redirecting the user to Linked In, but instead via the popup window.
The issue is, I'm not sure how to securely get an access token, which I can then use to get the users profile and create an account.
Currently, via the Javascript SDK, I can log the user in without redirection, and receive a oauth_token, which I then post to by backend. My Here is my code:
IN.User.authorize(function(){
$.ajax({
type: 'POST',
url: '/auth/li/'+IN.ENV.auth.oauth_token,
});
});
This succesfuly sends the token to my server, but how do I use it to then get an access token in order to use in the backend?
I tried to simply convert it to one using the LinkedIn API with
https://www.linkedin.com/oauth/v2/accessToken
but I get an error
Unable to retrieve access token: appid/redirect uri/code verifier does not match authorization code. Or authorization code expired.
I sort of understand the error, as with the javascript SDK there is no redirect URI.
With the Facebook SDK/API, on successful authorisation via the Javascript API, a cookie encrypted with my app secret is stored, and my backend can decrypt and read it, and then finally create an account.
Is there something like that in LinkedIn that I missed?
I have the same issue, with Google and Facebook SDK I can get access_token but linkedin SDK auth_token is not working. I think we need access_token but don't know how to get that with linkedin SDK.
I have come up with a solution. I ended up not using the javascript API. What I did was generate a login URL on my server and retrieved it via AJAX. I then created a javascript popup window and aimed it at the login url. One the user authenticates, linkedin redirects to my selected redirect URL within the popup, and I can then authenticate on my side (and close the popup).
I have iPhone application with an functionality of Login with facebook including few other functionalities related to graph API.
I receives facebook access token and save it to the server and server then makes further requests to graph API call from web end. As facebook access token expires after 60 days, I am getting access token expired error.
To solve this issue can i use FBSDKAccessToken.refreshCurrentAccessToken method to get new Access token ?
I did not find any clear idea for FBSDKAccessToken.refreshCurrentAccessToken.
OR Is there any other way to get new access token by performing automatic login with facebook from our application.
Thanks.
Native mobile apps using Facebook's SDKs will get long-lived access
tokens, good for about 60 days. These tokens will be refreshed once
per day when the person using your app makes a request to Facebook's
servers. If no requests are made, the token will expire after about 60
days and the person will have to go through the login flow again to
get a new token.
From the FB docs. ^
It seems the user will have to go through the login process in the app once again.
I am working on graph api to get user's liked pages videos. I have read https://developers.facebook.com/docs/ and requested for user_action.videos from Facebook. Now things becomes more confusing for me when i read about 1- OAuth Authentication, 2- temporary/long-lived access token and 3- test user as well.
1- As i believe as per my reading that OAuth Authentication for user is not required as it is done by FB SDK automatically. Is it right and if its wrong then how to authenticate user while using FB login dialogue as there is no URLRequest call in latest FB SDK login button?
2- After login through dialogue, I am getting an access token which is an expiry token and to keep user logged into my App; I have to convert that expiry token to long-lived token for 60 days every time when token is going to expire?
3- Is there any need for creating Test User in Facebook developer portal. Is there any role of it in development?
Any help would be greatly appreciated.
Goal
Fetch a company's updates save them locally in a background task
Problem
This should be done as a backend service without any real user interaction. We could provide a user account to use, but the authentication is a problem: There is literally no one to answer the OAuth redirect and there is no public redirect URL to configure, since it's a background service.
Is there any way to access the API without having a redirect URL or a real user?
You can get an initial access token in a regular front end flow, for you as the app developer i.e yourself as the LinkedIn user. Once you've got that, you can store it in the backend and use it for 60 days to get access to the LinkedIn APIs.
After 60 days you need to refresh the token as documented in:
https://developer.linkedin.com/documents/handling-errors-invalid-tokens
Unfortunately LinkedIn does not (yet) support an autonomous refresh flow where your app can get a new access token by presenting a refresh token on a backchannel. So the developer will have to refresh the access token by a manual login every 2 months.
Well, it is still all HTTP and HTML, so in fact there is no real reason to show the OAuth dialog to a user, as long you can strip out the necessary parts in the HTML authentication dialog and send a valid response back to the server, using the username and password from the user (which you can obtain from him, or save it yourself in a config file if it is you).
Note that there might be a legal issue if LinkedIn demands you to actually show the dialog, beside that, there is no technical need.
Is it possible to retrieve Facebook page posts in an iOS application without having to use Facebook Login?
I am currently using the Tumblr API which works perfectly fine and delivers pictures and texts from everything that has been posted.
Any help would be much appreciated.
Thanks.
Facebook SDK says, that you need any valid access token if the post is public. So just use your app access token.
Read how to request app access token here.
Yes, this is possible. There are two options from my point of view:
If your Page is only posting in public, you could use an App Access Token
If your Page also contains non-public Posts, you should use a Page Access Token
See https://developers.facebook.com/docs/graph-api/reference/v2.0/page/feed/#readperms
An access token is required to view publicly shared posts.
A user access token is required to retrieve posts visible to that person.
A page access token is required to retrieve any other posts.
An App Access Token will not expire unless you change your App secret, a Page Access Token will expire the latest 60 days after issuing.
You should consider to wrap this in an own webservice, so that you don't have to hard-code an Access Token into your App. With an own webservice, you could encapsulate the Access Token validity issues.
I recommend their graph api for such tasks
Using it I have successfully retrieved page level data using Facebook graph api(REST)
using an app token(public posts)
user token(posts visible to that user) or
page token(all posts in page)
App token is obtained by default on creation of your Facebook app(easiest way)
User token is obtained on a user oauth login(needs oauth,can be done with oauth libraries)
Page token is obtained with a second call to Facebook, after obtaining the user token if you have manage_pages permission from the page admin (needs oauth and a second call to Facebook)
Try Facebook graph explorer and hit the page URL to get a json response of your page information.
Play with the graph explorer
https://developers.facebook.com/tools/explorer/
Page data reference
https://developers.facebook.com/docs/graph-api/reference/v2.0/page/
Access token reference
https://developers.facebook.com/docs/facebook-login/access-tokens