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 registerUser method. This method will return an url which has to be opened in a browser where the registration can be continued. Which browser or webview to open for this is up to the developer.
If registration in the browser is successful, the browser will return a link has to be caught by ReactNative and passed to the SDK (e.g. with React Native Linking).
Resolve will be called when the whole flow is successfully finished and the pin creation is handled successfully. This flow can differ depending on the IDP that you have chosen.
There are two distinct flows that can be done to register on a device which are explained on their respective pages.
Create Pin
After completing the flow for browser based or custom registration you will have to register a pin in order to complete the registration. This is communicated by the SDK to React Native 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 the Pin Events
After receivingEvents.PinCreate.Open
the SDK expects the app to supply a pin. You can provide this pin with the submitPin
method.
If everything went properly registerUser will resolve with AuthData
object containing profile ID and optional custom info string.
Choosing an identity provider
To select an identity provider which will be used during the registration process you need to pass its id in the identityProviderId
parameter. To choose an identity provider, first you need to get all available providers. Call the method getIdentityProviders to get a list with available providers id. If this parameter isn’t specified or if its value is null
the default identity provider set on the Token Server will be used.
Cancel Registration
In some situations you want to cancel the registration flow, restart it, or start a different one. You can cancel browser registration and custom registration by their corresponding cancel methods, cancelBrowserRegistration and cancelCustomRegistration.
Canceling Registration is only possible through these methods when pin Creation has not yet started. When it has, use the cancelPinCreation method instead.