Possible to fetch authData in Parse database? - ios

I linked the user with their Facebook account with linkUserInBackground, and their Facebook ID is stored under authData inside the Parse.com database. I want to access this particular Facebook ID to retrieve the user's profile picture. Is this possible? If it is, how can I do so?

I think there are nothing to do with Parse.com, their linking function is just for logging user in.
You can call API from Facebook iOS SDK in order to get that image.
EDIT:
Although you use your Facebook ID to log in, you won't get the authData back when you query for it. So, the best way to do is to have your own custom field to store the Facebook ID so that it's available for you when you fetch it.
Extremely helpful documentation for getting Facebook ID after logging in:

Related

FBSDKAccessToken iOS SDK , identify a unique user for data

I am using Facebook login OAuth for my app. The reason behind posting this question is uniquely identify the Facebook id , by using userID or access token.
The data will be stored in a database, and should be uniquely identifiable for that Facebook logged-in user.
The currentAccessToken does change and we can configure a notification(FBSDKAccessTokenDidChangeNotification) when it changes.
So, I confused, that should I use userId or accessToken.
As, in case if user deletes the app. and wants the data back for the app. there should be unique identifier for that user.
So, will the following flow work or am I missing anything.
The data will be stored in a database, and should be uniquely identifiable for that Facebook logged-in user.
Use the user ID then. Your login flow seems fine.
Note that there are multiple ways of do this.
The client logs in and sends the access token to the server, then the server fetches the data.
The client logs in and fetches the data, then sends the data to the server.
You'd want to use the first method if the data needs to be reliable.

iOS, REST API - Facebook login

I'm studying how to develop an iOS app and I need to figure out how should I structure it.
Architecture:
I've an external database, a REST api (as interface between the database and the app), and the iOS app.
The question:
I'd like users to authenticate by a simple form or by a Facebook login button but in each case a table 'user' in the database has to be filled with default fields like name, surname, email, profile picture, password(?).
For the standard authentication there are no problem, but for Facebook authentication I'm quite confused about theory:
Should I use access token? How?
When a user get authenticated with Facebook I haven't his password, so how can I get his informations from the database? In the standard way I would give to the database username and password and it would return for example the id field.
Sorry for my english.
You can use the access token of current logged in user
[FBSDKAccessToken currentAccessToken]
and send it to your REST api. From there you can retrieve every information you need and save it to your database (except user's password of course). If a user sign in for first time in your app insert a new user in your database and save user's Facebook User ID.
The whole idea of using authenticate and authorization is not to have access to user's password of another app, but the user authorize (confirm) your app to have access in his/her account with specific permissions.
Here is a step-by-step answer of what you need:
Design for Facebook authentication in an iOS app that also accesses a secured web service
You need to save the currentAccessToken that the login request returns to you.
Then, using Facebook's Graph API, the userID that was returned in the login request, and the user access token, you can request a user object, which has the email address, assuming you added the email permission in the login request.
Also use the Graphi API to retrieve the user's photo using the userID that was returned in the login request:
50x50 pixels
<img src="//graph.facebook.com/{{fid}}/picture">
200 pixels width
<img src="//graph.facebook.com/{{fid}}/picture?type=large">

how to get facebook user id or user name with email id

I am developing a MVC project where I am trying to get the user id or user name from the facebook by using the email id provided by the user,
actually i want to fetch the photo of the user, which can be done using
graph.facebook.com/user_id|user_name/picture
where as i have only have the user email id.
with a little surfing on net i found that user name or user id can be fetched by using
graph.facebook.com/search?q=emailAddress&type=user&access_token=ACCESSTOKEN
but i was not able to get the access_token.
Also referred
developer facebook page
and also this
Any help or direction to work will help indeed.
Basically i understand that i need a access token to get the details.
So how do i do this in my MVC application
As you can read in the Search API docs, you can only search for Users by name, but not by E-Mail. It may have been possible in the past, but it is definitely not possible anymore.
Also, for searching by name, you need to use a User Access Token. You only get one by authorizing a User: https://developers.facebook.com/docs/facebook-login

Combining an online database and a Facebook login

I'm making an app and decided to go with a Facebook Login to log users into the app. This seems to be fairly easy, and Facebook has a great number of tutorials to use.
However, I want to retrieve (from my online database) a certain set of information related to individual users when the user logs in. How would I go about that?
That includes creating a row in my database for that specific user when it's his first time logging into the app (equivalent of registering for the app), and then inserting and retrieving information in different columns on that row.
So to start, how would I store that user in the database? Normally I'd have a user_id linked up to a username and password combination, but this time I don't have neither a username nor a password. I can't use their name, as more there might be more than one person with a name. Does Facebook give access to their user_id? If so, how do I retrieve it? If not, how would I go about doing that?
All your help would be greatly appreciated!
The Facebook FBGraphUser class provides access to basic user information including id and username properties. You don't say which method of logging in to Facebook you are using, but the Facebook Login Button/Login View calls the delegate method loginViewFetchedUserInfo:user where user is the FBGraphUser.
If you use the lower-level APIs then you will need to use the Graph API to obtain the user information.
A sample delegate method would be -
- (void) loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
{
NSLog(#"Facebook user id is %# and user name is %#",user.id,user.username);
}

Is it possible to fetch facebook user's profile without logging using facebook connect?

Basically, I want to fetch facebook profile avatars onto my application since I am using their login to create a particular record. How do we display their profile pic without actually forcing the user to connect into facebook to retrieve these pictures?
You can use the fbml fb:profile-pic tag or you can use the users.getinfo API call without the user logging in, however it will then use the default "everyone" privacy level for the pictures you're trying to get.

Resources