From 20226e2077077450862def88077890cc8c9ee1af Mon Sep 17 00:00:00 2001 From: Michael Costa Date: Fri, 25 Sep 2026 16:52:52 -0400 Subject: [PATCH] BCLOUD-14908, BCLOUD-14919 --- .../braincloud/client/AuthenticationType.java | 4 ++ .../braincloud/client/BrainCloudWrapper.java | 68 +++++++++++++++---- .../braincloud/client/IBrainCloudWrapper.java | 30 +++++--- .../braincloud/services/AppStoreService.java | 26 +++---- .../services/AuthenticationService.java | 22 +++++- .../braincloud/services/IdentityService.java | 53 +++++++++++++++ 6 files changed, 162 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/bitheads/braincloud/client/AuthenticationType.java b/src/main/java/com/bitheads/braincloud/client/AuthenticationType.java index f778d32..a95240a 100644 --- a/src/main/java/com/bitheads/braincloud/client/AuthenticationType.java +++ b/src/main/java/com/bitheads/braincloud/client/AuthenticationType.java @@ -16,6 +16,7 @@ public class AuthenticationType { public static final AuthenticationType GameCenter = new AuthenticationType("GameCenter"); public static final AuthenticationType Steam = new AuthenticationType("Steam"); public static final AuthenticationType Apple = new AuthenticationType("Apple"); + public static final AuthenticationType EpicGames = new AuthenticationType("EpicGames"); public static final AuthenticationType Google = new AuthenticationType("Google"); public static final AuthenticationType GoogleOpenId = new AuthenticationType("GoogleOpenId"); public static final AuthenticationType Twitter = new AuthenticationType("Twitter"); @@ -63,6 +64,9 @@ public static AuthenticationType fromString(String s) { if (s.equals(Apple.toString())) { return Apple; } + if (s.equals(EpicGames.toString())) { + return EpicGames; + } if (s.equals(Google.toString())) { return Google; } diff --git a/src/main/java/com/bitheads/braincloud/client/BrainCloudWrapper.java b/src/main/java/com/bitheads/braincloud/client/BrainCloudWrapper.java index e6db326..3fcf78b 100644 --- a/src/main/java/com/bitheads/braincloud/client/BrainCloudWrapper.java +++ b/src/main/java/com/bitheads/braincloud/client/BrainCloudWrapper.java @@ -554,25 +554,45 @@ public void authenticateGoogleOpenId(String googleOpenId, } /** - * Authenticate the user using an apple userid(email address) and apple - * authentication token. + * Authenticate the user using their Apple account and identityToken. * - * @param appleUserId String representation of apple userid (email) - * @param token The authentication token derived via the apple apis. - * @param forceCreate Should a new profile be created for this user if the account - * does not exist? - * @param callback The callback handler + * @param appleUserId String of the apple accounts user Id OR email + * @param identityToken The identityToken confirming users identity + * @param forceCreate Should a new profile be created for this user if the account + * does not exist? + * @param callback The callback handler */ @Override public void authenticateApple(String appleUserId, - String token, - boolean forceCreate, - IServerCallback callback) { + String identityToken, + boolean forceCreate, + IServerCallback callback) { + _authenticateCallback = callback; + + initializeIdentity(false); + + getClient().getAuthenticationService().authenticateApple(appleUserId, identityToken, forceCreate, this); + } + + /** + * Authenticate the user using an epicAccountId and their authIdToken. + * + * @param epicAccountId LocalUserId retrieved from the EOS AuthInterface's Login method. + * @param authIdToken IdToken string from the EOS AuthInterface's CopyIdToken method. + * @param forceCreate Should a new profile be created for this user if the account + * does not exist? + * @param callback The callback handler + */ + @Override + public void authenticateEpicGames(String epicAccountId, + String authIdToken, + boolean forceCreate, + IServerCallback callback) { _authenticateCallback = callback; initializeIdentity(false); - getClient().getAuthenticationService().authenticateApple(appleUserId, token, forceCreate, this); + getClient().getAuthenticationService().authenticateEpicGames(epicAccountId, authIdToken, forceCreate, this); } /** @@ -1036,7 +1056,29 @@ public void serverError(ServiceName serviceName, ServiceOperation serviceOperati } @Override - public void smartSwitchAuthenticateApple(String appleUserId, String token, boolean forceCreate, IServerCallback callback) + public void smartSwitchAuthenticateApple(String appleUserId, String identityToken, boolean forceCreate, IServerCallback callback) + { + getIdentitiesCallback(new IServerCallback() { + @Override + public void serverCallback(ServiceName serviceName, ServiceOperation serviceOperation, JSONObject jsonData) { + + // Clear IDs + resetStoredAnonymousId(); + resetStoredProfileId(); + getClient().getAuthenticationService().clearSavedProfileId(); + + authenticateApple(appleUserId, identityToken, forceCreate, callback); + } + + @Override + public void serverError(ServiceName serviceName, ServiceOperation serviceOperation, int statusCode, int reasonCode, String jsonError) { + callback.serverError(serviceName, serviceOperation, statusCode, reasonCode, jsonError); + } + }); + } + + @Override + public void smartSwitchAuthenticateEpicGames(String epicAccountId, String authIdToken, boolean forceCreate, IServerCallback callback) { getIdentitiesCallback(new IServerCallback() { @Override @@ -1047,7 +1089,7 @@ public void serverCallback(ServiceName serviceName, ServiceOperation serviceOper resetStoredProfileId(); getClient().getAuthenticationService().clearSavedProfileId(); - authenticateApple(appleUserId, token, forceCreate, callback); + authenticateEpicGames(epicAccountId, authIdToken, forceCreate, callback); } @Override diff --git a/src/main/java/com/bitheads/braincloud/client/IBrainCloudWrapper.java b/src/main/java/com/bitheads/braincloud/client/IBrainCloudWrapper.java index 2eb8abf..abfdc24 100644 --- a/src/main/java/com/bitheads/braincloud/client/IBrainCloudWrapper.java +++ b/src/main/java/com/bitheads/braincloud/client/IBrainCloudWrapper.java @@ -242,16 +242,26 @@ void authenticateGoogleOpenId(String googleOpenId, String googleAuthToken, boole IServerCallback callback); /** - * Authenticate the user using an apple userid(email address) and apple - * authentication token. + * Authenticate the user using their Apple account and identityToken. * - * @param appleUserId String representation of apple userid (email) - * @param token The authentication token derived via the apple apis. - * @param forceCreate Should a new profile be created for this user if the account - * does not exist? - * @param callback The callback handler + * @param appleUserId String of the apple accounts user Id OR email + * @param identityToken The identityToken confirming users identity + * @param forceCreate Should a new profile be created for this user if the account + * does not exist? + * @param callback The callback handler */ - void authenticateApple(String appleUserId, String token, boolean forceCreate, IServerCallback callback); + void authenticateApple(String appleUserId, String identityToken, boolean forceCreate, IServerCallback callback); + + /** + * Authenticate the user using an epicAccountId and their authIdToken. + * + * @param epicAccountId LocalUserId retrieved from the EOS AuthInterface's Login method. + * @param authIdToken IdToken string from the EOS AuthInterface's CopyIdToken method. + * @param forceCreate Should a new profile be created for this user if the account + * does not exist? + * @param callback The callback handler + */ + void authenticateEpicGames(String epicAccountId, String authIdToken, boolean forceCreate, IServerCallback callback); /** * Authenticate the user using a steam userid and session ticket (without @@ -507,7 +517,9 @@ void smartSwitchAuthenticateGoogle(String googleUserId, String serverAuthCode, b void smartSwitchAuthenticateGoogleOpenId(String googleUserAccountEmail, String IdToken, boolean forceCreate, IServerCallback callback); - void smartSwitchAuthenticateApple(String appleUserId, String token, boolean forceCreate, IServerCallback callback); + void smartSwitchAuthenticateApple(String appleUserId, String identityToken, boolean forceCreate, IServerCallback callback); + + void smartSwitchAuthenticateEpicGames(String epicAccountId, String authIdToken, boolean forceCreate, IServerCallback callback); void smartSwitchAuthenticateSteam(String steamUserId, String sessionTicket, boolean forceCreate, IServerCallback callback); diff --git a/src/main/java/com/bitheads/braincloud/services/AppStoreService.java b/src/main/java/com/bitheads/braincloud/services/AppStoreService.java index c0b40f0..cbc784f 100644 --- a/src/main/java/com/bitheads/braincloud/services/AppStoreService.java +++ b/src/main/java/com/bitheads/braincloud/services/AppStoreService.java @@ -45,6 +45,8 @@ public AppStoreService(BrainCloudClient client) { * - windows * - windowsPhone * - googlePlay + * - epicGames + * - xsolla * @param receiptData the specific store data required * @param callback The method to be invoked when the server response is received */ @@ -91,6 +93,8 @@ public void getEligiblePromotions(IServerCallback callback) { * - windows * - windowsPhone * - googlePlay + * - epicGames + * - xsolla * @param userCurrency The currency type to retrieve the sales inventory for. * @param callback The method to be invoked when the server response is received */ @@ -113,6 +117,8 @@ public void getSalesInventory(String storeId, String userCurrency, IServerCallba * - windows * - windowsPhone * - googlePlay + * - epicGames + * - xsolla * @param userCurrency The currency type to retrieve the sales inventory for. * @param category The product category * @param callback The method to be invoked when the server response is received @@ -143,14 +149,7 @@ public void getSalesInventoryByCategory(String storeId, String userCurrency, Str * Service Name - appStore * Service Operation - START_PURCHASE * - * @param storeId The store platform. Valid stores are: - * - itunes - * - facebook - * - appworld - * - steam - * - windows - * - windowsPhone - * - googlePlay + * @param storeId The store id. Currently only accepts "steam". * @param purchaseData specific data for purchasing 2 staged purchases * @param callback The method to be invoked when the server response is received */ @@ -173,14 +172,7 @@ public void startPurchase(String storeId, String jsonPurchaseData, IServerCallba * Service Name - appStore * Service Operation - FINALIZE_PURCHASE * - * @param storeId The store platform. Valid stores are: - * - itunes - * - facebook - * - appworld - * - steam - * - windows - * - windowsPhone - * - googlePlay + * @param storeId The store id. Currently only accepts "steam". * @param transactionId the transactionId returned from start Purchase * @param transactionData specific data for purchasing 2 staged purchases * @param callback The method to be invoked when the server response is received @@ -218,6 +210,8 @@ public void finalizePurchase(String storeId, String transactionId, String jsonTr * - windows * - windowsPhone * - googlePlay + * - epicGames + * - xsolla * @param transactionId the transactionId returned from start Purchase * @param transactionData specific data for purchasing 2 staged purchases * @param callback The method to be invoked when the server response is received diff --git a/src/main/java/com/bitheads/braincloud/services/AuthenticationService.java b/src/main/java/com/bitheads/braincloud/services/AuthenticationService.java index 706c3ac..9e68f02 100644 --- a/src/main/java/com/bitheads/braincloud/services/AuthenticationService.java +++ b/src/main/java/com/bitheads/braincloud/services/AuthenticationService.java @@ -269,13 +269,13 @@ public void authenticateOculus(String oculusUserId, String oculusNonce, boolean } /** - * Authenticate the user using a google userid(email address) and google authentication token. + * Authenticate the user using their Apple account and identityToken. * * Service Name - authenticationV2 * Service Operation - AUTHENTICATE * - * @param appleUserId String of the apple accounts user Id OR email - * @param identityToken The authentication token confirming users identity + * @param appleUserId String of the apple accounts user Id OR email + * @param identityToken The authentication token confirming users identity * @param forceCreate Should a new profile be created for this user if the account does not exist? * @param callback The method to be invoked when the server response is received */ @@ -284,6 +284,22 @@ public void authenticateApple(String appleUserId, String identityToken, boolean authenticate(appleUserId, identityToken, AuthenticationType.Apple, null, forceCreate, null, callback); } + /** + * Authenticate the user using an epicAccountId and their authIdToken. + * + * Service Name - authenticationV2 + * Service Operation - AUTHENTICATE + * + * @param epicAccountId LocalUserId retrieved from the EOS AuthInterface's Login method. + * @param authIdToken IdToken string from the EOS AuthInterface's CopyIdToken method. + * @param forceCreate Should a new profile be created for this user if the account does not exist? + * @param callback The method to be invoked when the server response is received + */ + public void authenticateEpicGames(String epicAccountId, String authIdToken, boolean forceCreate, + IServerCallback callback) { + authenticate(epicAccountId, authIdToken, AuthenticationType.EpicGames, null, forceCreate, null, callback); + } + /** * Authenticate the user using a google userid(email address) and google authentication token. * diff --git a/src/main/java/com/bitheads/braincloud/services/IdentityService.java b/src/main/java/com/bitheads/braincloud/services/IdentityService.java index 8ed15a4..2fa32a7 100644 --- a/src/main/java/com/bitheads/braincloud/services/IdentityService.java +++ b/src/main/java/com/bitheads/braincloud/services/IdentityService.java @@ -528,6 +528,59 @@ public void detachAppleIdentity(String appleId, boolean continueAnon, IServerCal detachIdentity(appleId, AuthenticationType.Apple, continueAnon, callback); } + /** + * Attach the user's EpicGames credentials to the current profile. + * + * Service Name - identity + * Service Operation - ATTACH + * + * @param epicAccountId LocalUserId retrieved from the EOS AuthInterface's Login method. + * @param authIdToken IdToken string from the EOS AuthInterface's CopyIdToken method. + * @param callback The method to be invoked when the server response is received + * + * Errors to watch for: SWITCHING_PROFILES - this means that the EpicGames identity you provided + * already points to a different profile. You will likely want to offer the user the + * choice to *SWITCH* to that profile, or *MERGE* the profiles. + * + * To switch profiles, call ClearSavedProfileID() and call AuthenticateEpicGames(). + */ + public void attachEpicGamesIdentity(String epicAccountId, String authIdToken, IServerCallback callback) { + attachIdentity(epicAccountId, authIdToken, AuthenticationType.EpicGames, callback); + } + + /** + * Merge the profile associated with the provided EpicGames credentials with the + * current profile. + * + * Service Name - identity + * Service Operation - MERGE + * + * @param epicAccountId LocalUserId retrieved from the EOS AuthInterface's Login method. + * @param authIdToken IdToken string from the EOS AuthInterface's CopyIdToken method. + * @param callback The method to be invoked when the server response is received + */ + public void mergeEpicGamesIdentity(String epicAccountId, String authIdToken, IServerCallback callback) { + mergeIdentity(epicAccountId, authIdToken, AuthenticationType.EpicGames, callback); + } + + /** + * Detach the EpicGames identity from this profile. + * + * Service Name - identity + * Service Operation - DETACH + * + * @param epicAccountId LocalUserId retrieved from the EOS AuthInterface's Login method. + * @param continueAnon Proceed even if the profile will revert to anonymous? + * @param callback The method to be invoked when the server response is received + * + * Watch for DOWNGRADING_TO_ANONYMOUS_ERROR - occurs if you set continueAnon to false, and + * disconnecting this identity would result in the profile being anonymous (which means that + * the profile wouldn't be retrievable if the user loses their device) + */ + public void detachEpicGamesIdentity(String epicAccountId, boolean continueAnon, IServerCallback callback) { + detachIdentity(epicAccountId, AuthenticationType.EpicGames, continueAnon, callback); + } + /**** EMAIL AND PASSWORD Methods ***/ /**