Socialid.login.getUserInfo

From Social ID Developers
(Difference between revisions)
Jump to: navigation, search
(Example)
 
(15 intermediate revisions by 3 users not shown)
Line 5: Line 5:
 
== Usage ==
 
== Usage ==
  
   socialid.login.getUserInfo(handler)
+
   socialid.login.getUserInfo(handler, options)
  
 
== Parameters ==
 
== Parameters ==
Line 12: Line 12:
 
! align="left" width="200px" | handler
 
! align="left" width="200px" | handler
 
| width="200px" | optional
 
| width="200px" | optional
| Callback function to handle the API response.
+
| callback function to handle the API response.
 +
|+
 +
! align="left" width="200px" | options
 +
| width="200px" | optional
 +
| object containing additional parameters.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | fields
 +
| width="200px" | optional
 +
| a list of user profile field names to be returned, joined by commas. See [[Social Profile Fields]].
 
|}
 
|}
  
Line 19: Line 27:
 
{|
 
{|
 
! align="left" width="200px" | data
 
! align="left" width="200px" | data
| Javascript object containing data from the user logged in. The object properties are: name, email, location, facebook, twitter, linkedin and gplus. The properties facebook, twitter, linkedin and gplus will be available only for the providers connected by the user.
+
| Javascript object containing data from the user logged in (see description below).
 
|+
 
|+
 
! align="left" width="200px" | status
 
! align="left" width="200px" | status
| The API response status. It could 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.
+
| 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:
 +
 
 +
{|
 +
! align="left" width="200px" | user_id
 +
| user's id.
 +
|-
 +
! align="left" width="200px" | username
 +
| user's username.
 +
|-
 +
! align="left" width="200px" | 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
 +
| a hash with the fields request by the parameter "fields". This field will only be present if at least one field is requested.
 +
|-
 +
! align="left" width="200px" | <span style="color: red">name</span>
 +
| <span style="color: red">user name. Warning: this field is deprecated. Use "display_name" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">email</span>
 +
| <span style="color: red">user e-mail. Warning: this field is deprecated. Use "verified_email" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">location</span>
 +
| <span style="color: red">user current location. Warning: this field is deprecated. Use "current_location" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">picture_url</span>
 +
| <span style="color: red">user picture url. Warning: this field is deprecated. Use "picture_url" field in the "fields" parameter.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">facebook</span>
 +
| <span style="color: red">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.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">twitter</span>
 +
| <span style="color: red">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.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">linkedin</span>
 +
| <span style="color: red">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.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">gplus</span>
 +
| <span style="color: red">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.</span>
 +
|-
 +
! align="left" width="200px" | <span style="color: red">instagram</span>
 +
| <span style="color: red">user Instagram profile data. This field will only be present if the user connected an Instagram credential. Warning: this field is deprecated. Use "providers" field in the "fields" parameter.</span>
 +
 
 
|}
 
|}
  
Line 32: Line 95:
 
   var handler = function(response) {
 
   var handler = function(response) {
 
     if (response.status == "success") {
 
     if (response.status == "success") {
         alert("Welcome " + data.name);
+
         alert("Welcome " + response.data.name);
 
     } else {
 
     } else {
 
         alert("Could not get info from the current logged in user.");
 
         alert("Could not get info from the current logged in user.");
Line 42: Line 105:
  
 
   data = {
 
   data = {
 +
    user_id: 632,
 +
    username: "john_doe",
 +
    email_address: "john_doe@domain.com",
 +
    active: true,
 +
    confirmed: true,
 +
    locked: false,
 
     name: "John Doe",
 
     name: "John Doe",
 
     email: "johndoe@example.com",
 
     email: "johndoe@example.com",
 
     location: "New York",
 
     location: "New York",
 +
    picture_url: "http://www.facebook.com/johndoe.jpg",
 
     facebook: {
 
     facebook: {
 
       picture_url: "http://www.facebook.com/johndoe.jpg",
 
       picture_url: "http://www.facebook.com/johndoe.jpg",
Line 60: Line 130:
 
       picture_url: "http://plus.google.com/johndoe.jpg",
 
       picture_url: "http://plus.google.com/johndoe.jpg",
 
       profile_url: "http://plus.google.com/johndoe"
 
       profile_url: "http://plus.google.com/johndoe"
 +
    },
 +
    instagram: {
 +
      picture_url: "http://www.instagram.com/johndoe.jpg",
 +
      profile_url: "http://www.instagram.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",
 +
    active: true,
 +
    confirmed: true,
 +
    locked: false,
 +
    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"
 +
        },
 +
        instagram: {
 +
          id: "5219840127213",
 +
          picture_url: "http://www.instagram.com/johndoe.jpg",
 +
          profile_url: "http://www.instagram.com/johndoe",
 +
          username: "johndoe"
 +
        },
 +
        apple: {
 +
          id: "8134.13472e1h21asas986asi12"
 +
        }
 +
      }
 +
    },
 +
    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"
 +
    },
 +
    instagram: {
 +
      picture_url: "http://www.instagram.com/johndoe.jpg",
 +
      profile_url: "http://www.instagram.com/johndoe",
 
     }
 
     }
 
   }
 
   }
  
 
You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground
 
You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground

Latest revision as of 22:15, 13 March 2020

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.
instagram user Instagram profile data. This field will only be present if the user connected an Instagram 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",
   active: true,
   confirmed: true,
   locked: false,
   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"
   },
   instagram: {
      picture_url: "http://www.instagram.com/johndoe.jpg",
      profile_url: "http://www.instagram.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",
   active: true,
   confirmed: true,
   locked: false,
   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"
       },
       instagram: {
         id: "5219840127213",
         picture_url: "http://www.instagram.com/johndoe.jpg",
         profile_url: "http://www.instagram.com/johndoe",
         username: "johndoe"
       },
       apple: {
         id: "8134.13472e1h21asas986asi12"
       }
     }
   },
   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"
   },
   instagram: {
      picture_url: "http://www.instagram.com/johndoe.jpg",
      profile_url: "http://www.instagram.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