title: Facebook Graph API - User ID unique?
body: <p>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:</p>
  
  <pre><code>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;
      }
  }
  </code></pre>
  
  <p>Basically, I have a service in angular that handles the Facebook login:</p>
  
  <pre><code>.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));
                              })
                          });
                      }
                  })
              });
          }
  
      })
  </code></pre>
  
  <p>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:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>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.</p>