I took the android app that can be downloaded when a native app is created in okta. In the authorized fragment, I’m trying to call my okta protected api that runs in a spring boot app:
private fun callMyApi() {
val uri: Uri = Uri.parse("https://myserv.com/myapi/endpoint")
val properties = hashMapOf<String, String>()
val postParameters: HashMap<String, String> = HashMap()
sessionClient?.run {
authorizedRequest(uri,
null,
null,
ConnectionParameters.RequestMethod.GET,
object : RequestCallback<JSONObject, AuthorizationException?> {
override fun onSuccess(result: JSONObject) {
info_view.text = "it worked!!!"
Snackbar.make(info_view, getString(R.string.success), Snackbar.LENGTH_SHORT)
.show()
}
override fun onError(
error: String,
exception: AuthorizationException?
) {
info_view.text = "it did not work screwed:"
Snackbar.make(info_view, getString(R.string.error), Snackbar.LENGTH_SHORT)
.show()
}
})
}
}
However, I keep on getting the following error, independent of whether I put empty collections instead of the two nulls or not:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.okta.oidc, PID: 8824
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter error
at com.okta.oidc.fragments.AuthorizedFragment$callMyStravaApi$$inlined$run$lambda$1.onError(Unknown Source:2)
at com.okta.oidc.fragments.AuthorizedFragment$callMyStravaApi$$inlined$run$lambda$1.onError(AuthorizedFragment.kt:117)
at com.okta.oidc.clients.sessions.SessionClientImpl.lambda$null$17(SessionClientImpl.java:136)
at com.okta.oidc.clients.sessions.-$$Lambda$SessionClientImpl$DCnATHgD-WNX9YAwRxWuhF6ZLKg.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
I/Process: Sending signal. PID: 8824 SIG: 9
Disconnected from the target VM, address: 'localhost:60989', transport: 'socket'
What could be the reason? How can I avoid this error?
I have also noticed that this method is deprecated, what other method should I call?