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.
- Kotlin
- Python
- Typescript
- Dart
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.
In the following example, the username and password are retrieved from the standard input:
CARDINAL_URL = "https://api.icure.cloud"
username = input("Username: ")
password = input("Password: ")
sdk = CardinalSdk(
application_id=None,
baseurl=CARDINAL_URL,
authentication_method=UsernamePassword(username, password),
storage_facade=FileSystemStorage("./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.
In the following example, the username and password are retrieved from the standard input:
const CARDINAL_URL = "https://api.icure.cloud"
const username = await readLn("Login: ")
const password = await readLn("Password: ")
const sdk = CardinalSdk.initialize(
undefined,
CARDINAL_URL,
new AuthenticationMethod.UsingCredentials.UsernamePassword(username, password),
StorageFacade.usingFileSystem("./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.
In the following example, the function initializes an SDK with a username and a password retrieved from the app UI:
const cardinalUrl = "https://api.icure.cloud";
Future<CardinalSdk> createSdk(String username, String password) async {
final sdk = await CardinalSdk.initialize(
null,
cardinalUrl,
AuthenticationMethod.UsingCredentials(Credentials.UsernamePassword(username, password)),
StorageOptions.PlatformDefault
);
return sdk;
}
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 native storage implementation (Androidx DataStore for Android,
NSUserDefaults for iOS, iPadOS, macOS & watchOS). If no key is found for the user, a new cryptographic key will be generated
and stored.
If you want to know more about the SDK initialization parameters, check this how to.