Get facebook Page Access Token using SLRequest - ios

How do I get Facebook Page Access Token using SLRequest (with a graph api call) on iOS.
I have an app that posts photos to a particular Facebook page. I've got it working through php so I know there is no issue with obtaining such permissions. But I need to do it completely in native iOS now.
In iOS, I've got post permission to said page owners feed, but that's not what I want. when I use the app token to post to a page (this is a photo album on a public facing page) it gives me 'permission denied errors'
I have this working through php using
$request = new FacebookRequest($session, 'GET',
'/me/accounts?fields=name,access_token,perms');
Just need to get the same for iOS using SLRequest as I'm using iOS Social framework
Thanks for the help

You should not make call to the Graph API using an App Access Token from a device. That is because the App Access Token should be considered like a password; storing it on a device is insecure because the token can be extracted using special software.
You can read more about this here: https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens
...Again, for security, app access token should never be hard-coded into client-side code...
You can handle your situation in two ways:
Just make the call using the User Access Token. If you have the correct permissions from the user, you can post as that page to the photo album.
Send the data to your own servers and make a call, using App Access Token, from there to the Graph API.
I would suggest you use method 1. Its also for your rate limiting better to use User tokens instead of App tokens.

Related

Azure Mobile Apps - Request user profile information

How do you make a request to Google to get a user's profile information with the returned tokens from Azure Mobile Apps? Specifically I am using the iOS Microsoft SDK in Objective-C.
I found this article but it looks to be referencing old information based on the date and the response that was returned.
I also tried calling /.auth/me as a GET request, but that returned Cannot GET /api/.auth/me
You need to make an HTTP request to /.auth/me, but without using the custom API support that's in the iOS SDK. In other words, use NSURLRequest directly, and not MSClient.invokeAPI. Your call needs to be authenticated, so put the token from client.currentUser.mobileServiceAuthenticationToken in the X-ZUMO-AUTH header.
We have an open feature request to add a method to the client SDKs to make this easier: https://github.com/Azure/azure-mobile-apps/issues/30.
And, you're right that your article was referencing information on Azure Mobile Services, which behaves completely differently when it comes to authentication.

Reading Twitter/Facebook information without Accounts via the iOS Social Framework

Is it possible to get Tweets/Facebook posts using the iOS Social Framework without using Facebook or Twitter accounts?
Not possible to query data without active account.
You can create new SLRequest, even set its parameters with valid FB access token but you will still need to associate the request with valid, accessible account.
See the example of the possible request here
For FB queries, You can use the FB SDK to perform the queries without active user login using access token generated for your facebook app, I can explain more about it if needed.

Retrieving and displaying third party Facebook statuses in iOS app

I'm new to Facebook development and I'm running into trouble with what seems like it should be an easy task. I am building an iOS app for a client, and that client wants to display a number of their most recent status updates in the app, along with a link to their Facebook page. These statuses should be displayed to the user of the app even if they are not logged into Facebook or do not have a Facebook account saved on their device.
My research so far seems to indicate that I'll need to make a request to the Graph API using a user access token (which I can do successfully in the app using a token copied and pasted from the Graph API Explorer), but it seems that the only way to get a user access token from within the app is to log the user of the app into Facebook using their account credentials. This is not a good solution because I need to be able to display the client's statuses to the user whether they have are logged into a Facebook account or not. Is such a thing possible, and if so, how? I've been all over the docs and can't find a conclusive answer either way.
I know that we would approach it quite differently. We would have our own web service periodically pull what we needed off of google and store it on our own server, then we would use AFHTTPClient to pull this information down to our app. That way we wouldn't have to spoof anything with FaceBook or put any requirments on our users, such as logging into facebook. It would require that you have a service that your client maintains (or you could easily contract that for a cost).

Sharing Facebook access token between iOS and website

I have developed a PHP website where users authenticate via Facebook and I get and store their auth_token.
On the other side, I have started developing an iOS app where users will be able to authenticate via Facebook too. The auth_token, as you know, will be different from the one that I got in the website auth process (same Facebook app as in the website)
My question is: can I use the auth_token that I got in the iOS app to make requests from the website? (same user, same app)
The reason is that sometimes I want some actions to be performed from the mobile device (ie. update status) while others to be performed from the web server (ie. checking which friends of the current user are already registered in my website)
thanks
Essentially, as long as you have a valid access_token for the specific user you can use it anywhere you want. Anywhere that you can execute an http request to Facebook and provide the correct parameters, you'll be able to make API calls on behalf of the user.
https://graph.facebook.com/USER_ID?access_token=XXX
This call should work regardless of where you execute it from.

Getting facebook wall posts without user login on iOS

Edit: I found the solution here:
Using app access token in IOS
Hi,
I read in this thread:
Facebook API without client authentication for public content
that it is possible to make facebook api graph requests without the need to log in as a user.
I tried getting the app access token with a NSURLConnection request,
but from there I don't know what to do.
How do I get the NSData response into the right format for the token (which is what, a NSString?)?
And how do I send a facebook graph request with the aquired token?
Or is there a simpler way to receive public posts from a facebook wall without the need to login as a user?
Greetings
Michael
Hey i'm struggling a litle bit with the same problem.
Since a couple of days Facebook changed some things concerning having an access tokken. Now, if you only want to read a users posts you will need to have an access token (even if this info is public).
Luckily you can also use the app access token. I'm trying to figure out how to fix this, but here is some information about that: http://developers.facebook.com/docs/authentication/ (chech app login)

Resources