I am using MSAL (Microsoft Authentication Library) in a Flutter app and when I try to run the app in release mode, it crashes with the following error:
Fatal Exception: java.lang.IllegalArgumentException: Invalid, null, or malformed redirect_uri supplied
at com.microsoft.identity.client.PublicClientApplicationConfiguration.validateRedirectUri(:45)
at com.microsoft.identity.client.PublicClientApplicationConfiguration.validateConfiguration(:2)
at com.microsoft.identity.client.PublicClientApplicationConfigurationFactory.initializeConfigurationInternal(:14)
at com.microsoft.identity.client.PublicClientApplicationConfigurationFactory.initializeConfiguration(:9)
at com.microsoft.identity.client.PublicClientApplication$7.run(:4)
at java.lang.Thread.run(Thread.java:764)
I am using native code in my Flutter app and I have properly configured the redirect URI for my app, but I am still seeing this error.
I am creating a JSON file in native android and passing
client_id, resource_id, redirect_ui, tenant_id
From flutter to native android because we have different users with different credentials like client_id, redirect_ui etc. And that JSON file we're using native android.
PublicClientApplication.createSingleAccountPublicClientApplication(context, File("/data/data/" + context.getPackageName().toString() + "/" +"config.json"),
object : ISingleAccountApplicationCreatedListener {
override fun onCreated(application: ISingleAccountPublicClientApplication) {
mSingleAccountApp = application
callBack(LoginModel(error = false,message = "initialized data",token = null))
loadAccount()
}
override fun onError(exception: MsalException) {
callBack(LoginModel(error = true,message = exception.message,token = null))
}
})
The is the method for initializing object of ISingleAccountPublicClientApplication and it was working fine in debug mode.
I have tried double-checking the redirect URI configuration, checking for typos or other mistakes in the URI, and checking for issues with the authorization request, but I am still having trouble resolving this issue.
Any help or suggestions on how to troubleshoot this error would be greatly appreciated.