User registration
This topic guide explains the steps required to perform user registration.
The Onegini SDK uses the OAuth 2.0 protocol to authorize the device to access protected resources. To support this protocol the SDK acts as an OAuth 2.0 client.
Prerequisites
To initialize authentication the client credentials are required. These credentials are received via Dynamic Client Registration (DCR). As an app developer, there is no need to initialize DCR as it is part of the default implementations in the SDK.
As a timestamp is used within the DCR protocol it is mandatory that the time on the device is equal to the time on the Token Server, independent of time zones. In case of a wrong time the SDK will return an error.
Start Registration
The user registration starts with enrolling a user on a device using a selected Identity Provider (IdP). The list of all possible IdPs for an app is configured in the Token Server admin panel. The TS also configures a default (primary) IdP that is used for backward compatibility.
To start the user registration you have to call the User registration method.
Depending on the IdP, different registration flows will be followed to register on a device. There are two distinct flows that can be done which are explained on their respective pages:
After completing the flow for browser based or custom registration you will have to register a pin in order to complete the registration. Once this has succeeded te registration will be completed.
Create Pin
As mentioned previously, once the registration flows are finished a pin needs to be created. This is communicated by the SDK to Flutter through events. The app will have to listen to these Events and respond to them accordingly.
The following snippet shows how you can listen for Pin Events
Once a user decides on a pin, the pin will then need to be communicated back to the flutter SDK. This can be done through the following method:
If an invalid pin is passed on to the acceptAuthenticationRequest
method, an showError event will be thown. In case everything went properly registerUser will resolve with a RegistrationResponse
object.
Choosing an Identity Providers
With the identityProviderId
paramater from registerUser, you can decide which IdP will be used during the registration process. The available providers on the Token Server can be obtained through the getIdentityProviders method. If this parameter isn’t specified or if its value is null
the default identity provider set on the Token Server will be used.