Facebook Graph API - User ID unique?

mwilson

I am trying to figure out a good way to store a unique ID for a user in my app. I am using facebook login for user management and have a class for the user:

function FacebookUser(userObj) {
    if (userObj) {
        this.name = userObj.name;
        this.id = userObj.id;
        this.picture = userObj.picture.data.url;
        this.isLoggedIn = true;
    } else {
        this.name = 'Login';
        this.id = 0;
        this.picture = '';
        this.isLoggedIn = false;
    }
}

Basically, I have a service in angular that handles the Facebook login:

.service('facebookService', function () {

        this.getFacebookUser = function (callback) {
            $.getScript("//connect.facebook.net/en_US/sdk.js", function () {
                var appId = "12312312313123";
                FB.init({
                    appId: appId,
                    status: true,
                    cookie: true,
                    xfbml: true,
                    version: 'v2.4'
                });

                FB.getLoginStatus(function (response) {
                    if (response.status == 'connected') {
                        FB.api('/me?fields=picture,name,email', function (data) {
                            callback(new FacebookUser(data));
                        })
                    } else {
                        FB.login(function (response) {
                            FB.api('/me?fields=picture,name,email', function (data) {
                                callback(new FacebookUser(data));
                            })
                        });
                    }
                })
            });
        }

    })

What I'm trying to figure out is what the unique identifier is. I would like to just use the email address of the user since it's guarenteed to be unique but don't want to ask for extra permissions. Originally, I wanted to use the id field but I'm unclear on if the id is going to ever change or not. In the facebook documentation, they explain the id field as such:

The id of this person's user account. This ID is unique to each app and cannot be used across different apps. Our upgrade guide provides more information about app-specific IDs

According to this, the ID is unique to the app and cannot be used across different apps. However, I am trying to get a little more clarity here. If one user logs into the app today and then again in a couple months, will their ID be the same (if it's the same app) or will it change? Secondary question would be that if/when I make a change and get a new app id, will the ID be the same or change? It's technically still the same app, just a different version. My assumption is that since it's a different appId, facebook thinks it's a completely different app but I'm new to the facebook api and looking to the experts for advice.

Trapsilo Bumi

I'm not an expert, but I will try to answer your questions.

If one user logs into the app today and then again in a couple months, will their ID be the same (if it's the same app) or will it change?

As long as the App ID is the same, the user ID will not change, even between logins, no matter how long in between.

Secondary question would be that if/when I make a change and get a new app id, will the ID be the same or change?

A new App ID means a different App, which means the user ID will change. But if you get a new App ID and need to access the same user, you can use facebook's Business Mapping API.

Excerpt from facebook docs:

If you need to map the same user IDs across multiple apps or run cross-app promotions, we've added a new API called the Business Mapping API. This lets you map a logged-in user's IDs across apps as long as those apps are all owned by the same business.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Facebook Graph API unique id

From Dev

Getting the user context id for a Facebook Open Graph API query

From Dev

Get Users App-Scoped user id in Facebook Graph API

From Dev

Facebook Graph api 2.2 - App scoped user id uniqueness

From Dev

Get Facebook User Profile ID instead of App-Scoped user id in Facebook Graph API

From Dev

Facebook Graph API stopped sending user email

From Dev

Get tags on user photos facebook graph api

From Dev

Facebook Graph API (How to get user gender?)

From Dev

Facebook Graph API only returns user name

From Dev

Facebook Graph API User object subscriptions Whitelisting

From Dev

Facebook Graph API: How to access user movies?

From Dev

Facebook Graph API only returns user name

From Dev

Facebook Graph API Limited User Data Set

From Dev

facebook getting user id from graph api via taggable_friends

From Dev

Facebook Graph API v2.1: getting user id and his posts

From Dev

What viewController to use with Facebook Graph API /{user-id}/feed (iOS)

From Dev

Facebook Graph API Object_id

From Dev

Facebook Graph API Object_id

From Dev

Facebook Graph API/SDK .NET - Get PageID of a Facebook user

From Dev

Why is the Facebook user id picked up by Firebase different to the Facebook id associated with the same account in the Facebook Graph?

From Dev

Get ALL User Friends Using Facebook Graph API - Android

From Dev

Facebook Graph API: Making public post on user's page

From Dev

PHP Facebook Graph API get posts comments WITH user photo field

From Dev

Facebook Graph API Call Without Using User Login

From Dev

How to retrieve user country using facebook Graph API?

From Dev

Get a list of pages a user has in Facebook with Graph API

From Dev

Facebook Graph API v2.4 not returning extended user data

From Dev

android facebook java get user name with Graph API

From Dev

Accessing user feed using Facebook Graph API v2.0

Related Related

  1. 1

    Facebook Graph API unique id

  2. 2

    Getting the user context id for a Facebook Open Graph API query

  3. 3

    Get Users App-Scoped user id in Facebook Graph API

  4. 4

    Facebook Graph api 2.2 - App scoped user id uniqueness

  5. 5

    Get Facebook User Profile ID instead of App-Scoped user id in Facebook Graph API

  6. 6

    Facebook Graph API stopped sending user email

  7. 7

    Get tags on user photos facebook graph api

  8. 8

    Facebook Graph API (How to get user gender?)

  9. 9

    Facebook Graph API only returns user name

  10. 10

    Facebook Graph API User object subscriptions Whitelisting

  11. 11

    Facebook Graph API: How to access user movies?

  12. 12

    Facebook Graph API only returns user name

  13. 13

    Facebook Graph API Limited User Data Set

  14. 14

    facebook getting user id from graph api via taggable_friends

  15. 15

    Facebook Graph API v2.1: getting user id and his posts

  16. 16

    What viewController to use with Facebook Graph API /{user-id}/feed (iOS)

  17. 17

    Facebook Graph API Object_id

  18. 18

    Facebook Graph API Object_id

  19. 19

    Facebook Graph API/SDK .NET - Get PageID of a Facebook user

  20. 20

    Why is the Facebook user id picked up by Firebase different to the Facebook id associated with the same account in the Facebook Graph?

  21. 21

    Get ALL User Friends Using Facebook Graph API - Android

  22. 22

    Facebook Graph API: Making public post on user's page

  23. 23

    PHP Facebook Graph API get posts comments WITH user photo field

  24. 24

    Facebook Graph API Call Without Using User Login

  25. 25

    How to retrieve user country using facebook Graph API?

  26. 26

    Get a list of pages a user has in Facebook with Graph API

  27. 27

    Facebook Graph API v2.4 not returning extended user data

  28. 28

    android facebook java get user name with Graph API

  29. 29

    Accessing user feed using Facebook Graph API v2.0

HotTag

Archive