diff --git a/android/README.md b/android/README.md index 9c0d55e..5dc552c 100644 --- a/android/README.md +++ b/android/README.md @@ -55,7 +55,7 @@ The Asgardeo Android SDK is developed using Kotlin and is built using the Androi ``` This will publish the SDK to the local Maven repository. You can find the SDK in the following location. ``` - ~/.m2/repository/org/io/asgardeo/asgardeo-android/ + ~/.m2/repository/io/asgardeo/asgardeo-android/ ``` You can also find the SDK in the `External Libraries` section in the project view of Android Studio. 3. Note the version of the SDK that you have released to the local Maven repository. You can find the version in the `gradle.properties` file in the root of the SDK project, in the variable `MAIN_VERSION`. @@ -99,6 +99,10 @@ You can test the changes by running any Android application and including the SD } } ``` + > [!TIP] + > There are some reports that the `mavenLocal()` repository is not being resolved in the `settings.gradle` file. To + > resolve this issue, please refer to this StackOverflow [thread](https://stackoverflow.com/questions/32107205/gradle-does-not-use-the-maven-local-repository-for-a-new-dependency). + 3. Build and run the sample application using the above mentioned [documentation](https://github.com/wso2/samples-is/blob/master/petcare-sample/b2c/mobile-app/petcare-with-sdk/README.md). diff --git a/android/core-auth-direct/src/main/java/io/asgardeo/android/core_auth_direct/core/managers/flow/impl/FlowManagerImpl.kt b/android/core-auth-direct/src/main/java/io/asgardeo/android/core_auth_direct/core/managers/flow/impl/FlowManagerImpl.kt index 212774f..f9ea332 100644 --- a/android/core-auth-direct/src/main/java/io/asgardeo/android/core_auth_direct/core/managers/flow/impl/FlowManagerImpl.kt +++ b/android/core-auth-direct/src/main/java/io/asgardeo/android/core_auth_direct/core/managers/flow/impl/FlowManagerImpl.kt @@ -103,6 +103,9 @@ internal class FlowManagerImpl private constructor() : FlowManager { * TODO: Need to check additional check to flowid to check if the flow is the same as the current flow */ override fun manageStateOfAuthorizeFlow(responseObject: JsonNode): AuthenticationFlow { + // Get the messages from the response object + val messages: JsonNode? = responseObject.get("nextStep")?.get("messages") + return when (responseObject.get("flowStatus").asText()) { /** * TODO: Add exact error message returned from Asgardeo to the FlowManagerException @@ -112,7 +115,8 @@ internal class FlowManagerImpl private constructor() : FlowManager { */ FlowStatus.FAIL_INCOMPLETE.flowStatus -> { throw FlowManagerException( - FlowManagerException.AUTHENTICATION_NOT_COMPLETED + message = FlowManagerException.AUTHENTICATION_NOT_COMPLETED, + messages = if (messages != null) arrayListOf(messages) else arrayListOf() ) } @@ -126,7 +130,8 @@ internal class FlowManagerImpl private constructor() : FlowManager { else -> { throw FlowManagerException( - FlowManagerException.AUTHENTICATION_NOT_COMPLETED_UNKNOWN + message = FlowManagerException.AUTHENTICATION_NOT_COMPLETED_UNKNOWN, + messages = if (messages != null) arrayListOf(messages) else arrayListOf() ) } } diff --git a/android/core-auth-direct/src/main/java/io/asgardeo/android/core_auth_direct/models/exceptions/FlowManagerException.kt b/android/core-auth-direct/src/main/java/io/asgardeo/android/core_auth_direct/models/exceptions/FlowManagerException.kt index 9c2364b..5d66d76 100644 --- a/android/core-auth-direct/src/main/java/io/asgardeo/android/core_auth_direct/models/exceptions/FlowManagerException.kt +++ b/android/core-auth-direct/src/main/java/io/asgardeo/android/core_auth_direct/models/exceptions/FlowManagerException.kt @@ -24,7 +24,8 @@ import io.asgardeo.android.core_auth_direct.core.managers.flow.FlowManager * Exception to be thrown to the exception related to [FlowManager] */ class FlowManagerException( - override val message: String? + override val message: String?, + val messages: ArrayList = arrayListOf() ) : Exception(message) { companion object { /** diff --git a/docs/website/android/error-handling.md b/docs/website/android/error-handling.md index df2b1cc..743cd90 100644 --- a/docs/website/android/error-handling.md +++ b/docs/website/android/error-handling.md @@ -53,8 +53,12 @@ is AuthenticationState.Error -> { Also if you want to show an error message in the TextFields, you have to navigate to the login component and show the error message. -> [!NOTE] -> There is an issue in the SDK that the exact error message provided from Asgardeo is not correctly passed to the `FlowManagerException`. This is a known issue that is tracked in the [GitHub repository](https://github.com/asgardeo/mobile-ui-sdks/issues/44). +To view the specific error message, you can use the the `messages` property of the `FlowManagerException` as shown below: + +```kotlin +val messages: ArrayList = (it.throwable as FlowManagerException).messages +``` +This will return an array of error messages that is returned by Asgardeo, explaining the error in detail. ### Authenticator Not Found Error