Skip to main content

Initialize the SDK

After you have created a first database and a healthcare party user with a token, you can use those credentials to instantiate a new iCure SDK. In the following example, the username and password are retrieved from the standard input:

private const val CARDINAL_URL = "https://api.icure.cloud"

print("Login: ")
val username = readln().trim()
print("Password: ")
val password = readln().trim()
val sdk = CardinalSdk.initialize(
applicationId = null,
baseUrl = CARDINAL_URL,
authenticationMethod = AuthenticationMethod.UsingCredentials(
UsernamePassword(username, password)
),
baseStorage = FileStorageFacade("./scratch/storage")
)

The initialize function creates an instance of the SDK with the provided username and password. It also attempts to load existing cryptographic keys for the user from the ./scratch/storage folder. If no key is found for the user in that folder, a new cryptographic key will be generated and stored there. If you want to know more about the SDK initialization parameters, check this how to.