Response handling
The closure onStatusChange
returns the OktaAuthStatus
instance as a parameter. An instance of the OktaAuthStatus
class represents the current status that is returned by the server. It's your responsibilty to handle current status in order to proceed with the initiated flow. Check the status type by calling status.statusType
and downcast to a concrete status class.
Example handler function:
Success status handling
Downcast the received status to the OktaAuthStatusSuccess
class and get access to the sessionToken
property. You can then exchange the session token for an access token via the OktaOidc
library.
Error handling
Errors are returned via the onError
closure. Handle the error
parameter of type OktaError
to get the error condition.
Example of the OktaError
definition:
Note that some errors have underlying raw values of different types, such as String
, Error
, OktaAPIErrorResponse
, and so on. Raw values give additional context about the error and simplify error handling and troubleshooting. For example, serverRespondedWithError
indicates that the API errors and also carries server-side data encapsulated in the OktaAPIErrorResponse
class. The following example shows how to extract a server-side error response: