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 as described in Event handling. The app will have to listen to these Events and respond to them accordingly.
Create Pin Events
For more information on how to handle events and which attribute information the events might contain, see Event handling. The events that occur during the creation of the pin are described below:
Event | Description |
---|---|
OpenPinCreationEvent | Fired after starting the create pin flow |
ClosePinCreationEvent | Fired after supplying a valid pin for the registration and the pin has been registered. |
PinNotAllowedEvent | Fired when a pin is given that does not conform to the set pin policy on the token server. |
Create Pin Flow
The first event that will be thrown after the registration to set a pin will be the openPinRegistration
event. A user can listen to this event using the following example code:
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 pinNotAllowedEvent
event will be thrown. In case everything went properly an ClosePinRegistrationEvent
event will be thrown and the registerUser function will resolve with an OWRegistrationResponse 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.