Socialid.login.moveTo
Renato.neves (Talk | contribs) |
Renato.neves (Talk | contribs) (→Description) |
||
Line 1: | Line 1: | ||
== Description == | == Description == | ||
− | API to move data from the user logged in the current login session to another user identified by "userId" and "userToken" and then '''removes the user that was logged in | + | API to move data from the user logged in the current login session to another user identified by "userId" and "userToken" and then '''removes the user that was logged in'''. The another user "userId" will inherit the previous connection, that is, this user will be logged in the current login session. |
The "userId" and "userToken" can be retrieved from [[GET login/info]] or [[GET login/users/:user_id]] APIs. | The "userId" and "userToken" can be retrieved from [[GET login/info]] or [[GET login/users/:user_id]] APIs. |
Revision as of 12:16, 4 November 2014
Contents |
Description
API to move data from the user logged in the current login session to another user identified by "userId" and "userToken" and then removes the user that was logged in. The another user "userId" will inherit the previous connection, that is, this user will be logged in the current login session.
The "userId" and "userToken" can be retrieved from GET login/info or GET login/users/:user_id APIs.
A common use case for this API is to merge users when you known they are the same person.
Important: see Social Login Tokens for detailed information about the tokens used by the Social Login and best security practices.
Usage
socialid.login.moveTo(userId, userToken, handler)
Parameters
userId | required | Identifier of the target user, for which you want to move the data from the user currently logged. | userToken | required | Token of the target user. | handler | optional | Callback function to handle the API response. |
---|
API Response
data | Always "null". This API does not return data. | status | The API response status. Can be success, if the user has been moved successfully, not_found, if there is no user currently logged, or forbidden if the provided credentials are not allowed to perform this operation. |
---|
Example
Moves data from the user currently logged in to the user identified by the userId "34" and userToken "1234567890" and then removes the user that was logged in:
var handler = function(response) { if (response.status == "success") { alert("User successfully moved."); } else if (response.status == "not_found") { alert("There is no user logged in at the moment."); } else { alert("UserId and userToken do not match."); } } var appId = 1, userId = 34, userToken = '1234567890'; socialid.login.init(appId); socialid.login.moveTo(userId, userToken, handler);
You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground