Skip to main content

MaestroAuthData

Overview

MaestroAuthData is a data class that encapsulates authentication information used by the Maestro SDK. It contains user authentication credentials that can be used to identify and authorize users within the SDK ecosystem.

Syntax

data class MaestroAuthData(
val swid: String? = null,
val jwtToken: String? = null
)

Properties

PropertyTypeDefaultDescription
swidString?nullSession-Wide Identifier (SWID). An optional identifier that can be used for session tracking and user identification.
jwtTokenString?nullJSON Web Token for authentication. An optional JWT token that provides secure authentication credentials for API requests and user verification.

Usage Example

// Create auth data with SWID only
val authData = MaestroAuthData(
swid = "user-session-id-12345"
)

// Create auth data with JWT token only
val authData = MaestroAuthData(
jwtToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
)

// Create auth data with both SWID and JWT token
val authData = MaestroAuthData(
swid = "user-session-id-12345",
jwtToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
)

// Create empty auth data (both fields null)
val authData = MaestroAuthData()

// Use in event delegate callback
override fun authData(): MaestroAuthData {
return MaestroAuthData(
swid = getUserSessionId(),
jwtToken = getAuthToken()
)
}

Common Use Cases

Authenticated User Flow

class MyActivity : MaestroEventDelegate {
private var userToken: String? = null
private var sessionId: String? = null

override fun authData(): MaestroAuthData {
return MaestroAuthData(
swid = sessionId,
jwtToken = userToken
)
}

fun onUserLogin(token: String, session: String) {
userToken = token
sessionId = session
// SDK will use updated auth data for subsequent requests
}

fun onUserLogout() {
userToken = null
sessionId = null
// SDK will receive null values for auth data
}
}

Guest User Flow

override fun authData(): MaestroAuthData {
// Return empty auth data for guest users
return MaestroAuthData()
}

Notes

  • Both properties are optional and default to null
  • Typically provided through the authData() method of MaestroEventDelegate
  • The SDK may call authData() multiple times, so ensure your implementation returns current values
  • Keep authentication tokens secure and avoid logging them
  • Update the auth data when user authentication state changes (login/logout)

Security Considerations

  • Store tokens securely using Android's encrypted storage mechanisms
  • Do not hardcode authentication credentials
  • Implement proper token refresh mechanisms
  • Clear auth data on logout to prevent unauthorized access
  • Consider token expiration and renewal strategies

See Also