Socialid.login.moveTo
Renato.neves (Talk | contribs) (→Description) |
Renato.neves (Talk | contribs) |
||
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. 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. | |
− | <span style="color: red"> | + | <span style="color: red">Important:</span> see [[Social Login Tokens]] for detailed information about the tokens used by the Social Login and best security practices. |
== Usage == | == Usage == | ||
Line 17: | Line 17: | ||
{| | {| | ||
! align="left" width="200px" | userId | ! align="left" width="200px" | userId | ||
− | | width="200px" | | + | | width="200px" | required |
− | | | + | | Identifier of the target user, for which you want to move the data from the user currently logged. |
|+ | |+ | ||
! align="left" width="200px" | userToken | ! align="left" width="200px" | userToken | ||
− | | width="200px" | | + | | width="200px" | required |
− | | Token | + | | Token of the target user. |
|+ | |+ | ||
! align="left" width="200px" | handler | ! align="left" width="200px" | handler | ||
− | | width="200px" | | + | | width="200px" | optional |
− | | | + | | Callback function to handle the API response. |
|} | |} | ||
Line 33: | Line 33: | ||
{| | {| | ||
! align="left" width="200px" | data | ! align="left" width="200px" | data | ||
− | | | + | | Always "null". This API does not return data. |
|+ | |+ | ||
! align="left" width="200px" | status | ! align="left" width="200px" | 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. |
|} | |} | ||
Revision as of 12:10, 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
Move o usuário da sessão atual para um outro usuário identificado por userId e userToken:
var handler = function(response) { if (response.status == "success") { alert("Usuário movido com sucesso"); } else if (response.status == "not_found") { alert("Não há usuário logado no momento."); } else { alert("User_id e user_token não conferem."); } } var appId = 1, userId = 34, userToken = '1234567890'; socialid.login.init(appId); socialid.login.moveTo(userId, userToken, handler);
Teste as APIs em nosso playground: https://sid-examples.herokuapp.com/social_logins/playground