Socialid.login.getUserInfo
From Social ID Developers
(Difference between revisions)
Renato.neves (Talk | contribs) |
Renato.neves (Talk | contribs) (→Example) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 39: | Line 39: | ||
{| | {| | ||
! align="left" width="200px" | user_id | ! align="left" width="200px" | user_id | ||
− | | 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> | ! align="left" width="200px" | <span style="color: red">name</span> | ||
Line 52: | Line 70: | ||
! align="left" width="200px" | <span style="color: red">picture_url</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> | | <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> | ! align="left" width="200px" | <span style="color: red">facebook</span> | ||
Line 67: | Line 82: | ||
! align="left" width="200px" | <span style="color: red">gplus</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> | | <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 87: | Line 106: | ||
data = { | data = { | ||
user_id: 632, | 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", | ||
Line 106: | 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", | ||
} | } | ||
} | } | ||
Line 125: | Line 153: | ||
data = { | data = { | ||
user_id: 632, | 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", | ||
Line 157: | Line 190: | ||
profile_url: "http://plus.google.com/johndoe", | profile_url: "http://plus.google.com/johndoe", | ||
username: "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" | ||
} | } | ||
} | } | ||
Line 175: | Line 217: | ||
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", | ||
} | } | ||
} | } | ||
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. |
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. |
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. | |
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. | |
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. |
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