diff --git a/src/Packages/Passport/Runtime/Scripts/Private/Core/Model/BrowserResponse.cs b/src/Packages/Passport/Runtime/Scripts/Private/Core/Model/BrowserResponse.cs index ec897f8b..884a4e11 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/Core/Model/BrowserResponse.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/Core/Model/BrowserResponse.cs @@ -8,12 +8,12 @@ public class BrowserResponse public string requestId; public bool success; public string errorType; - public string error; + public string? error; } public class StringResponse : BrowserResponse { - public string result; + public string? result; } public class StringListResponse : BrowserResponse diff --git a/src/Packages/Passport/Runtime/Scripts/Private/Model/Response/TokenResponse.cs b/src/Packages/Passport/Runtime/Scripts/Private/Model/Response/TokenResponse.cs index c3e3186c..f7c17108 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/Model/Response/TokenResponse.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/Model/Response/TokenResponse.cs @@ -5,10 +5,10 @@ namespace Immutable.Passport.Model [Serializable] public class TokenResponse { - public string accessToken; - public string refreshToken; - public string idToken; - public string tokenType; - public int expiresIn; + public string access_token; + public string refresh_token; + public string id_token; + public string token_type; + public int expires_in; } } \ No newline at end of file diff --git a/src/Packages/Passport/Runtime/Scripts/Private/PassportFunction.cs b/src/Packages/Passport/Runtime/Scripts/Private/PassportFunction.cs index 01022de0..cbf6100f 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/PassportFunction.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/PassportFunction.cs @@ -14,6 +14,7 @@ public static class PassportFunction public const string GET_EMAIL = "getEmail"; public const string GET_PASSPORT_ID = "getPassportId"; public const string GET_LINKED_ADDRESSES = "getLinkedAddresses"; + public const string STORE_TOKENS = "storeTokens"; public static class IMX { public const string GET_ADDRESS = "getAddress"; diff --git a/src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs b/src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs index 1f0deb8d..623f2a53 100644 --- a/src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs +++ b/src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs @@ -503,6 +503,13 @@ public async UniTask HasCredentialsSaved() } } + public async UniTask CompleteLogin(TokenResponse request) + { + var json = JsonUtility.ToJson(request); + var callResponse = await _communicationsManager.Call(PassportFunction.STORE_TOKENS, json); + return callResponse.GetBoolResponse() ?? false; + } + public async UniTask GetAddress() { var response = await _communicationsManager.Call(PassportFunction.IMX.GET_ADDRESS); diff --git a/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs b/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs index adc56033..37924535 100644 --- a/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs +++ b/src/Packages/Passport/Runtime/Scripts/Public/Passport.cs @@ -309,6 +309,18 @@ public async UniTask ConnectImx(bool useCachedSession = false, DirectLogin return await GetPassportImpl().ConnectImx(useCachedSession, directLoginMethod); } + /// + /// Completes the login process by storing the token. This is required for the login to be complete. + /// + /// The token request + /// + /// True if successful, otherwise false. + /// + public async UniTask CompleteLogin(TokenResponse request) + { + return await GetPassportImpl().CompleteLogin(request); + } + /// /// Gets the wallet address of the logged in user. ///