diff --git a/Assets/Stash/Scripts/Core/StashConstants.cs b/Assets/Stash/Scripts/Core/StashConstants.cs
index 9af78c3..f26b93f 100644
--- a/Assets/Stash/Scripts/Core/StashConstants.cs
+++ b/Assets/Stash/Scripts/Core/StashConstants.cs
@@ -15,6 +15,7 @@ public class StashConstants
public const string CustomLogin = "/sdk/custom_login/approve_with_jwt";
public const string LoginAppleGameCenter = "/sdk/custom_login/approve_apple_game_center";
public const string LoginGooglePlayGames = "/sdk/custom_login/google_play";
+ public const string LoginFacebook = "/sdk/custom_login/facebook_auth";
}
}
diff --git a/Assets/Stash/Scripts/Core/StashCustomLogin.cs b/Assets/Stash/Scripts/Core/StashCustomLogin.cs
index 8fa2b7e..35db36d 100644
--- a/Assets/Stash/Scripts/Core/StashCustomLogin.cs
+++ b/Assets/Stash/Scripts/Core/StashCustomLogin.cs
@@ -22,6 +22,7 @@ public static class StashCustomLogin
/// Player identification, that will be used to identify purchases.
/// Valid identification token (OICD) of the player.
/// URL to the player's profile image/avatar to be displayed during login and on web shop.
+ /// Stash API environment (Defaults to Test).
/// Returns a confirmation response, or throws StashAPIRequestError if fails.
public static async Task CustomLogin(string code, string playerId, string idToken, string profileImageUrl, StashEnvironment environment = StashEnvironment.Test)
{
@@ -146,6 +147,7 @@ public static async Task LinkAppleGameCenter(string code, string p
/// Stash code challenge from the deeplink.
/// Player identification, that will be used to identify purchases.
/// The authorization code generated using RequestServerSideAccess
+ /// Stash API environment (Defaults to Test).
/// A LinkResponse object.
public static async Task LinkGooglePlayGames(string code, string playerId, string authCode, StashEnvironment environment = StashEnvironment.Test)
{
@@ -186,5 +188,58 @@ public static async Task LinkGooglePlayGames(string code, string p
throw new StashRequestError(result.StatusCode, result.Data);
}
}
+
+
+
+ ///
+ /// Logs in to stash web shop via Facebook account.
+ /// Requires valid access token generated from Facebook login.
+ ///
+ /// Stash code challenge from the deeplink.
+ /// Player identification, that will be used to identify purchases.
+ /// Facebook app id.
+ /// Facebook access token.
+ /// Stash API environment (Defaults to Test).
+ /// A LinkResponse object.
+ public static async Task LinkFacebook(string code, string playerId, string appId, string accessToken, StashEnvironment environment = StashEnvironment.Test)
+ {
+ // Create the request body with the challenge and internal user id
+ var requestBody = new LoginFacebook()
+ {
+ code = code,
+ appId = appId,
+ inputToken = accessToken,
+ user = new LoginFacebook.User()
+ {
+ id = playerId
+ }
+ };
+
+ // Set the URL for the link account endpoint
+ string requestUrl = environment.GetRootUrl() + StashConstants.LoginGooglePlayGames;
+ // Make a POST request to link the access token
+ Response result = await RestClient.Post(requestUrl, JsonUtility.ToJson(requestBody));
+
+ // Check the response status code
+ if (result.StatusCode == 200)
+ {
+ try
+ {
+ Debug.Log("[RESPONSE RAW] " + result.Data);
+ LinkResponse resultResponse = JsonUtility.FromJson(result.Data);
+ return resultResponse;
+ }
+ catch
+ {
+ // Throw an error if there is an issue parsing the response data
+ throw new StashParseError(result.Data);
+ }
+ }
+ else
+ {
+ // Throw an error if the API request was not successful
+ throw new StashRequestError(result.StatusCode, result.Data);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Assets/Stash/Scripts/Models/LoginFacebook.cs b/Assets/Stash/Scripts/Models/LoginFacebook.cs
new file mode 100644
index 0000000..511595f
--- /dev/null
+++ b/Assets/Stash/Scripts/Models/LoginFacebook.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace Stash.Models
+{
+ [Serializable]
+ public class LoginFacebook
+ {
+ public string code;
+ public string appId;
+ public string inputToken;
+ public User user;
+
+ [Serializable]
+ public class User
+ {
+ public string id;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Stash/Scripts/Models/LoginFacebook.cs.meta b/Assets/Stash/Scripts/Models/LoginFacebook.cs.meta
new file mode 100644
index 0000000..78e0374
--- /dev/null
+++ b/Assets/Stash/Scripts/Models/LoginFacebook.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: fb30523338f04d0c896357585ab7b49b
+timeCreated: 1721813988
\ No newline at end of file