Juan L
Juan L

Reputation: 1731

android: log user via facebook,what to store in my user database to identify it univocally and be able to relate it to the other tables

I'm in the dilemma of

1)At starting the app, showing my own login screen and storing it on my own user table and then let the user associate his facebook account and store the access token in my DB on that same table

2)just let the user login with facebook and set the permisions to get the userId or something unique and immutable from his facebook account and store it in my database as a way of identifying the user cause I have to do some relationships with the data on my other tables and the user, but if that data changes in facebook I won't have data consistency..

I have for example on my database:

Tables 

Events

Id_event
description
etc
id_user

event_posts
id_event
id_post
id_user
description

I need some identification for the user even if the user logs in with facebook, what can I do to identify it properly on the app and have a consistent database?

Upvotes: 0

Views: 212

Answers (1)

sonique
sonique

Reputation: 4772

You should save the UserId from Facebook, it's a long value and the access token returned by Facebook, if you want to keep the session alive.

Android SDK provide the Profile class where you can get the id

Reference: https://developers.facebook.com/docs/reference/android/current/class/Profile/

Upvotes: 1

Related Questions