Socialid.login.getUserInfo

(Difference between revisions)
Jump to: navigation, search
(Example)
(Response Data)
Line 46: Line 46:
 
! align="left" width="200px" | email_address
 
! align="left" width="200px" | email_address
 
| user's email_address.
 
| user's email_address.
 +
|-
 +
! align="left" width="200px" | active
 +
| boolean flag to inform whether the user is activated for login.
 +
|-
 +
! align="left" width="200px" | confirmed
 +
| boolean flag to inform whether the user has confirmed his email address.
 +
|-
 +
! align="left" width="200px" | locked
 +
| boolean flag to inform whether the user is locked due to too many login attempts with an incorrect password.
 
|-
 
|-
 
! align="left" width="200px" | profile
 
! align="left" width="200px" | profile

Revision as of 20:36, 18 December 2019

Contents

Description

API to get basic information about the user logged in the current login session.

Usage

 socialid.login.getUserInfo(handler, options)

Parameters

handler optional callback function to handle the API response.
options optional object containing additional parameters.
fields optional a list of user profile field names to be returned, joined by commas. See Social Profile Fields.

API Response

data Javascript object containing data from the user logged in (see description below).
status The API response status. Can be success, if there is an user logged in the current login session and its data was successfully retrieved, or not_found, if there is no user logged in the current login session.

Response Data

The data object properties are:

user_id user's id.
username user's username.
email_address user's email_address.
active boolean flag to inform whether the user is activated for login.
confirmed boolean flag to inform whether the user has confirmed his email address.
locked boolean flag to inform whether the user is locked due to too many login attempts with an incorrect password.
profile a hash with the fields request by the parameter "fields". This field will only be present if at least one field is requested.
name user name. Warning: this field is deprecated. Use "display_name" field in the "fields" parameter.
email user e-mail. Warning: this field is deprecated. Use "verified_email" field in the "fields" parameter.
location user current location. Warning: this field is deprecated. Use "current_location" field in the "fields" parameter.
picture_url user picture url. Warning: this field is deprecated. Use "picture_url" field in the "fields" parameter.
facebook user Facebook profile data. This field will only be present if the user connected a Facebook credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.
twitter user Twitter profile data. This field will only be present if the user connected a Twitter credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.
linkedin user LinkedIn profile data. This field will only be present if the user connected a LinkedIn credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.
gplus user Google+ profile data. This field will only be present if the user connected a Google+ credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.

Example

Get basic information about the user logged in the current login session:

 socialid.login.init(1);
 var handler = function(response) {
    if (response.status == "success") {
       alert("Welcome " + response.data.name);
    } else {
       alert("Could not get info from the current logged in user.");
    }
 }
 socialid.login.getUserInfo(handler);

Example of "data" object:

 data = {
   user_id: 632,
   username: "john_doe",
   email_address: "john_doe@domain.com",
   name: "John Doe",
   email: "johndoe@example.com",
   location: "New York",
   picture_url: "http://www.facebook.com/johndoe.jpg",
   facebook: {
      picture_url: "http://www.facebook.com/johndoe.jpg",
      profile_url: "http://www.facebook.com/johndoe"
   },
   twitter: {
      picture_url: "http://www.twitter.com/johndoe.jpg",
      profile_url: "http://www.twitter.com/johndoe"
   },
   linkedin: {
      picture_url: "http://www.linkedin.com/johndoe.jpg",
      profile_url: "http://www.linkedin.com/johndoe"
   },
   gplus: {
      picture_url: "http://plus.google.com/johndoe.jpg",
      profile_url: "http://plus.google.com/johndoe"
   }
 }

Get information about the user logged in the current login session using the "fields" parameter:

 socialid.login.init(1);
 var handler = function(response) {
    if (response.status == "success") {
       alert("Welcome " + response.data.profile.display_name);
    } else {
       alert("Could not get info from the current logged in user.");
    }
 }
 socialid.login.getUserInfo(handler, {fields: "display_name,verified_email,current_location,picture_url,providers"});

Example of "data" object:

 data = {
   user_id: 632,
   username: "john_doe",
   email_address: "john_doe@domain.com",
   name: "John Doe",
   email: "johndoe@example.com",
   location: "New York",
   picture_url: "http://www.facebook.com/johndoe.jpg",
   profile: {
     display_name: "John Doe",
     verified_email: "johndoe@example.com",
     current_location: "New York",
     picture_url: "http://www.facebook.com/johndoe.jpg",
     providers: {
       facebook: {
         id: "4235242",
         picture_url: "http://www.facebook.com/johndoe.jpg",
         profile_url: "http://www.facebook.com/johndoe",
         username: "johndoe"
       },
       twitter: {
         id: "7435242",
         picture_url: "http://www.twitter.com/johndoe.jpg",
         profile_url: "http://www.twitter.com/johndoe",
         username: "johndoe"
       },
       linkedin: {
         id: "https://www.linkedin.com/in/johndoe",
         picture_url: "http://www.linkedin.com/johndoe.jpg",
         profile_url: "http://www.linkedin.com/johndoe"
       },
       gplus: {
         id: "3158238193",
         picture_url: "http://plus.google.com/johndoe.jpg",
         profile_url: "http://plus.google.com/johndoe",
         username: "johndoe"
       }
     }
   },
   facebook: {
      picture_url: "http://www.facebook.com/johndoe.jpg",
      profile_url: "http://www.facebook.com/johndoe"
   },
   twitter: {
      picture_url: "http://www.twitter.com/johndoe.jpg",
      profile_url: "http://www.twitter.com/johndoe"
   },
   linkedin: {
      picture_url: "http://www.linkedin.com/johndoe.jpg",
      profile_url: "http://www.linkedin.com/johndoe"
   },
   gplus: {
      picture_url: "http://plus.google.com/johndoe.jpg",
      profile_url: "http://plus.google.com/johndoe"
   }
 }

You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox