Service configurations are only needed for the Direct InApp-Authentication feature and must be supplied in order of it to work. Note, if the XignIn-Manager uses a Keycloak server for the user data management, this step can be skipped.
The service configuration files can be downloaded via the frontend of the XignIn-Manager. The setup of a service at the XignIn-Manager is described in the server's documentation. The download will result in a ZIP file named after the service. The ZIP file contains several files from which only the "your-service-name".json file is relevant. The file should roughly look like this:
JSON
{
"manager": {
"tokenUrl": "https://sdk.xignin.dev/api/rp/token",
"statusUrl": "https://sdk.xignin.dev/api/rp/state/check"
},
"client": {
"name": "SDK-EC-Asymmetric-Service",
"clientId": "89b3081a-0dda-4aa4-aae8-f6185d90ab19",
"loginUri": "https://localhost/",
"redirectUri": "https://localhost/"
}
}
Note: The file contains more values than shown in this example. Every other value except the shown ones in this example is not relevant for the InApp-Authentication feature of the SDK and must not be added to the app.
The values of the fields must be added to a XignSdkConfig.Builder via
addServiceConfiguration(clientId:tokenUrl:statusUrl:redirectUrl:loginUri:serviceName:).
The following example shows a XignSdk initialization with an optional configuration object containing a service configuration. The service used is only an example, please do not use these exact values in your application.
private func initializationWithServiceConfiguration(_ application: UIApplication) throws {
let sdkConfig: XignSdkConfig = try XignSdkConfig.with { builder in
// add possible service configurations for the direct InApp-Authentication feature
try builder.addServiceConfiguration(
clientId: "92d763f9-034c-44d8-bb2b-4b01b73d5941",
tokenUrl: URL(string: "https://sdk.xignin.dev/api/rp/token")!,
statusUrl: URL(string: "https://sdk.xignin.dev/api/rp/state/check")!,
redirectUrl: URL(string: "https://localhost/")!,
loginUri: URL(string: "https://localhost/")!,
serviceName: "SDK-InApp-EC-Symmetric-Service"
)
// add more configurations if needed
// ...
}
try XignSdk.initialize(application: application, config: sdkConfig)
// After a successful initialization the instance of the XignSdk class can be accessed as follows:
let xignSdk: XignSdk = XignSdk.shared
// Important: Accessing the instance before initialization (or after de-initialization) results in
// a NSException!
}
private fun initializationWithServiceConfiguration(context: Context) {
val sdkConfig: XignSdkConfig = XignSdkConfig.with { builder ->
// add possible service configurations for the direct InApp-Authentication feature
builder.addServiceConfiguration(
clientId = "92d763f9-034c-44d8-bb2b-4b01b73d5941",
tokenUrl = URL("https://sdk.xignin.dev/api/rp/token"),
statusUrl = URL("https://sdk.xignin.dev/api/rp/state/check"),
redirectUrl = URL("https://localhost/"),
loginUri = URL("https://localhost/"),
serviceName = "SDK-InApp-EC-Symmetric-Service"
)
// add more configurations if needed
// ...
}
XignSdk.initialize(context = context, config = sdkConfig)
// After a successful initialization the instance of the XignSdk class can be accessed as follows:
val xignSdk: XignSdk = XignSdk.shared
// Important: Accessing the instance before initialization (or after de-initialization) results in
// an IllegalStateException!
}