signIn method
Signs in a user with the given credentials.
Two authentication modes are supported:
Mode 1: Token-based — pass accessToken and refreshToken.
The SDK will use these tokens directly for API calls and will
automatically refresh the access token on 401 errors.
Mode 2: API key — pass apiKey.
The SDK will send X-Open-Wearables-API-Key header with each request.
On 401, emits an auth error event (no automatic refresh for API keys).
You must provide either (accessToken + refreshToken) or (apiKey).
Implementation
@override
Future<void> signIn({
required String userId,
String? accessToken,
String? refreshToken,
String? apiKey,
}) async {
try {
await _channel.invokeMethod<void>('signIn', {
'userId': userId,
if (accessToken != null) 'accessToken': accessToken,
if (refreshToken != null) 'refreshToken': refreshToken,
if (apiKey != null) 'apiKey': apiKey,
});
} on PlatformException catch (e) {
throw SignInException(e.message ?? 'Sign-in failed', statusCode: int.tryParse(e.code));
}
}