diff --git a/docs/godot/identifying.mdx b/docs/godot/identifying.mdx index 6764892..6dcd450 100644 --- a/docs/godot/identifying.mdx +++ b/docs/godot/identifying.mdx @@ -1,6 +1,6 @@ --- sidebar_position: 2 -description: The Talo Godot plugin allows you to identify multiple aliases, authenticate and sync your players with Steamworks. +description: The Talo Godot plugin allows you to identify multiple aliases, authenticate and sync your players with Steamworks and Google Play. --- import { ScopeBadges } from '@site/src/components/ScopeBadges' @@ -100,7 +100,7 @@ There are a few limitations to merging players: - **Player 2** cannot have a Talo Player Authentication, Steam or Google Play Games alias. - If **Player 1** has a Talo Player Authentication, Steam or Google Play Games alias, the merge must be initiated while identified as **Player 1** (i.e. `Talo.current_alias` must belong to Player 1). In this case, make sure your last `Talo.players.identify()` call before merging uses Player 1's alias. - Both players cannot have overlapping alias services. For example, if both players have an alias with the service "username", the merging process will fail. -::: + ::: You can provide the `post_merge_identity_service` option to automatically re-identify the player once merging is complete: diff --git a/docs/godot/player-authentication.mdx b/docs/godot/player-authentication.mdx index 0cdd0d8..488daea 100644 --- a/docs/godot/player-authentication.mdx +++ b/docs/godot/player-authentication.mdx @@ -229,6 +229,41 @@ You can provide your players with a self-service deletion link. This can be foun When an alias is deleted, all leaderboard entries and game feedback associated with that alias will be deleted. Any channels owned by the alias will now have a `null` owner. +## Migrating accounts + + + +You can migrate a player's account to a different service and identifier using `Talo.player_auth.migrate_account()`. You'll need to provide the player's current password, the new service (e.g. `username`, `steam`, `google_play_games`) and the new identifier. The original player auth account will be deleted and they will only be able to use their new identifier. + +Here is an example of migrating to a [Steam alias](/docs/godot/identifying#steamworks-integration): + +```gdscript +@onready var current_password: TextEdit = %CurrentPassword +@onready var new_service: OptionButton = %NewService +@onready var new_identifier: TextEdit = %NewIdentifier +@onready var validation_label: Label = %ValidationLabel + +var ticket_identity := "talo" + +func _ready() -> void: + Steam.steamInitEx() + Steam.get_ticket_for_web_api.connect(_on_get_ticket_for_web_api) + Steam.getAuthTicketForWebApi(ticket_identity) + +func _on_get_ticket_for_web_api(_auth_ticket: int, _result: int, _ticket_size: int, ticket_buffer: Array) -> void: + _migrate_account(PackedByteArray(ticket_buffer).hex_encode()) + +func _migrate_account(ticket: String) -> void: + var res = await Talo.player_auth.migrate_account(current_password.text, "steam", "%s:%s" % [ticket_identity, ticket]) + + if res != OK: + validation_label.text = Talo.player_auth.last_error.get_string() +``` + +You can also migrate to the `google_play_games` service by providing an [auth code](/docs/godot/identifying#google-play-games-integration). + +When a migration is successful, the current session is cleared, the player's alias is updated to the new service and identifier, and the `Talo.players.identified` signal is emitted. + ## Getting the last error As shown in the examples above, whenever a request fails you can query the last error returned using the `Talo.player_auth.last_error` variable. diff --git a/docs/http/player-auth-api.mdx b/docs/http/player-auth-api.mdx index 39eae8f..7ba22b8 100644 --- a/docs/http/player-auth-api.mdx +++ b/docs/http/player-auth-api.mdx @@ -166,3 +166,25 @@ When attempting to toggle verification on, this error is thrown if the player do errorCode: 'VERIFICATION_EMAIL_REQUIRED' } ``` + +### `EMAIL_TAKEN` + +When registering an auth account with email verification, enabling email verification or changing an account's email, this error will be thrown if another player is already using the chosen email address. + +```javascript +{ + message: 'This email address is already in use', + errorCode: 'EMAIL_TAKEN' +} +``` + +### `INVALID_MIGRATION_TARGET` + +When starting a player auth account migration, this error is thrown if an invalid service is provided. Currently the only invalid service is "talo". + +```javascript +{ + message: 'Cannot migrate to the Talo service', + errorCode: 'INVALID_MIGRATION_TARGET' +} +``` diff --git a/docs/unity/identifying.mdx b/docs/unity/identifying.mdx index 150e7df..c940a1e 100644 --- a/docs/unity/identifying.mdx +++ b/docs/unity/identifying.mdx @@ -1,6 +1,6 @@ --- sidebar_position: 2 -description: The Talo Unity package allows you to identify multiple aliases, authenticate and sync your players with Steamworks. +description: The Talo Unity package allows you to identify multiple aliases, authenticate and sync your players with Steamworks and Google Play. --- import { ScopeBadges } from '@site/src/components/ScopeBadges' @@ -25,7 +25,7 @@ using TaloGameServices; public class IdentifyPlayer: MonoBehaviour { - public string service = 'steam', identifier = '123456'; + public string service = 'username', identifier = '123456'; public void OnButtonClick() { @@ -135,7 +135,7 @@ There are a few limitations to merging players: - **Player 2** cannot have a Talo Player Authentication, Steam or Google Play Games alias. - If **Player 1** has a Talo Player Authentication, Steam or Google Play Games alias, the merge must be initiated while identified as **Player 1** (i.e. `Talo.CurrentAlias` must belong to Player 1). In this case, make sure your last `Talo.Players.Identify()` call before merging uses Player 1's alias. - Both players cannot have overlapping alias services. For example, if both players have an alias with the service "username", the merging process will fail. -::: + ::: You can provide the `post_merge_identity_service` option to automatically re-identify the player once merging is complete: diff --git a/docs/unity/player-authentication.mdx b/docs/unity/player-authentication.mdx index acee9cd..19fec6e 100644 --- a/docs/unity/player-authentication.mdx +++ b/docs/unity/player-authentication.mdx @@ -271,6 +271,45 @@ You can provide your players with a self-service deletion link. This can be foun When an alias is deleted, all leaderboard entries and game feedback associated with that alias will be deleted. Any channels owned by the alias will now have a `null` owner. +## Migrating accounts + + + +You can migrate a player's account to a different service and identifier using `Talo.PlayerAuth.MigrateAccount()`. You'll need to provide the player's current password, the new service (e.g. `username`, `steam`, `google_play_games`) and the new identifier. The original player auth account will be deleted and they will only be able to use their new identifier. + +Here is an example of migrating to a [Steam alias](/docs/unity/identifying#steamworks-integration): + +```csharp +Callback m_AuthTicketForWebApiResponseCallback; +string ticketIdentity = "talo"; + +void MigrateToSteam() +{ + m_AuthTicketForWebApiResponseCallback = Callback.Create(OnAuthCallback); + SteamUser.GetAuthTicketForWebApi(ticketIdentity); +} + +async void OnAuthCallback(GetTicketForWebApiResponse_t callback) +{ + var ticket = BitConverter.ToString(callback.m_rgubTicket).Replace("-", string.Empty); + m_AuthTicketForWebApiResponseCallback.Dispose(); + m_AuthTicketForWebApiResponseCallback = null; + + try + { + await Talo.PlayerAuth.MigrateAccount(currentPassword, "steam", $"{ticketIdentity}:{ticket}"); + } + catch (PlayerAuthException ex) + { + validationLabel.text = ex.Message; + } +} +``` + +You can also migrate to the `google_play_games` service by providing an [auth code](/docs/unity/identifying#google-play-games-integration). + +When a migration is successful, the current session is cleared, the player's alias is updated to the new service and identifier, and the `OnPlayerIdentified` event is invoked. + ## Exceptions and error codes As shown in the examples above, whenever a request fails with an authentication-related error, a `PlayerAuthException` will be thrown.