diff --git a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/LoginApiRequestHandler.kt b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/LoginApiRequestHandler.kt index ba5409bf..b84fb6e3 100644 --- a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/LoginApiRequestHandler.kt +++ b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/LoginApiRequestHandler.kt @@ -8,7 +8,6 @@ import com.auth0.auth0_flutter.request_handlers.MethodCallRequest import com.auth0.auth0_flutter.toMap import com.auth0.auth0_flutter.utils.assertHasProperties import io.flutter.plugin.common.MethodChannel -import java.text.SimpleDateFormat import java.util.* private const val AUTH_LOGIN_METHOD = "auth#login" @@ -54,10 +53,7 @@ class LoginApiRequestHandler : ApiRequestHandler { override fun onSuccess(credentials: Credentials) { val scope = credentials.scope?.split(" ") ?: listOf() - val sdf = - SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US) - - val formattedDate = sdf.format(credentials.expiresAt) + val formattedDate = credentials.expiresAt.toInstant().toString() result.success( mapOf( "accessToken" to credentials.accessToken, diff --git a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/LoginWithOtpApiRequestHandler.kt b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/LoginWithOtpApiRequestHandler.kt index c3c8f6a1..62e22668 100644 --- a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/LoginWithOtpApiRequestHandler.kt +++ b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/LoginWithOtpApiRequestHandler.kt @@ -8,7 +8,6 @@ import com.auth0.auth0_flutter.request_handlers.MethodCallRequest import com.auth0.auth0_flutter.toMap import com.auth0.auth0_flutter.utils.assertHasProperties import io.flutter.plugin.common.MethodChannel -import java.text.SimpleDateFormat import java.util.* private const val AUTH_LOGIN_OTP_METHOD = "auth#loginOtp" @@ -42,10 +41,7 @@ class LoginWithOtpApiRequestHandler: ApiRequestHandler { override fun onSuccess(credentials: Credentials) { val scope = credentials.scope?.split(" ") ?: listOf() - val sdf = - SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US) - - val formattedDate = sdf.format(credentials.expiresAt) + var formattedDate = credentials.expiresAt.toInstant().toString() result.success( mapOf( "accessToken" to credentials.accessToken, diff --git a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/RenewApiRequestHandler.kt b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/RenewApiRequestHandler.kt index 62d43643..3fc5dc38 100644 --- a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/RenewApiRequestHandler.kt +++ b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/api/RenewApiRequestHandler.kt @@ -8,8 +8,6 @@ import com.auth0.auth0_flutter.request_handlers.MethodCallRequest import com.auth0.auth0_flutter.toMap import com.auth0.auth0_flutter.utils.assertHasProperties import io.flutter.plugin.common.MethodChannel -import java.text.SimpleDateFormat -import java.util.Locale private const val AUTH_RENEW_METHOD = "auth#renew" @@ -46,10 +44,7 @@ class RenewApiRequestHandler : ApiRequestHandler { override fun onSuccess(credentials: Credentials) { val scope = credentials.scope?.split(" ") ?: listOf() - val sdf = - SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US) - - val formattedDate = sdf.format(credentials.expiresAt) + val formattedDate = credentials.expiresAt.toInstant().toString(); result.success( mapOf( diff --git a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/credentials_manager/GetCredentialsRequestHandler.kt b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/credentials_manager/GetCredentialsRequestHandler.kt index 31549dae..664d5ea2 100644 --- a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/credentials_manager/GetCredentialsRequestHandler.kt +++ b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/credentials_manager/GetCredentialsRequestHandler.kt @@ -8,7 +8,6 @@ import com.auth0.android.result.Credentials import com.auth0.auth0_flutter.request_handlers.MethodCallRequest import com.auth0.auth0_flutter.toMap import io.flutter.plugin.common.MethodChannel -import java.text.SimpleDateFormat import java.util.* class GetCredentialsRequestHandler : CredentialsManagerRequestHandler { @@ -38,11 +37,7 @@ class GetCredentialsRequestHandler : CredentialsManagerRequestHandler { override fun onSuccess(credentials: Credentials) { val scopes = credentials.scope?.split(" ") ?: listOf() - val sdf = - SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US) - - val formattedDate = sdf.format(credentials.expiresAt) - + val formattedDate = credentials.expiresAt.toInstant().toString() result.success( mapOf( "accessToken" to credentials.accessToken, diff --git a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/credentials_manager/SaveCredentialsRequestHandler.kt b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/credentials_manager/SaveCredentialsRequestHandler.kt index 6a395c53..5955f0bc 100644 --- a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/credentials_manager/SaveCredentialsRequestHandler.kt +++ b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/credentials_manager/SaveCredentialsRequestHandler.kt @@ -6,8 +6,7 @@ import com.auth0.android.result.Credentials import com.auth0.auth0_flutter.request_handlers.MethodCallRequest import com.auth0.auth0_flutter.utils.assertHasProperties import io.flutter.plugin.common.MethodChannel -import java.text.SimpleDateFormat -import java.time.LocalDate +import java.time.Instant import java.util.* @@ -32,15 +31,14 @@ class SaveCredentialsRequestHandler : CredentialsManagerRequestHandler { scope = scopes.joinToString(separator = " ") } - val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US) - val date = format.parse(credentials.get("expiresAt") as String) + val instant = Instant.parse(credentials.get("expiresAt") as String) credentialsManager.saveCredentials(Credentials( credentials.get("idToken") as String, credentials.get("accessToken") as String, credentials.get("tokenType") as String, credentials.get("refreshToken") as String?, - date, + Date.from(instant), scope, )) result.success(true) diff --git a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/web_auth/LoginWebAuthRequestHandler.kt b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/web_auth/LoginWebAuthRequestHandler.kt index 0251a172..b11ab41f 100644 --- a/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/web_auth/LoginWebAuthRequestHandler.kt +++ b/auth0_flutter/android/src/main/kotlin/com/auth0/auth0_flutter/request_handlers/web_auth/LoginWebAuthRequestHandler.kt @@ -8,7 +8,6 @@ import com.auth0.android.result.Credentials import com.auth0.auth0_flutter.request_handlers.MethodCallRequest import com.auth0.auth0_flutter.toMap import io.flutter.plugin.common.MethodChannel -import java.text.SimpleDateFormat import java.util.* class LoginWebAuthRequestHandler(private val builderResolver: (MethodCallRequest) -> WebAuthProvider.Builder) : WebAuthRequestHandler { @@ -69,10 +68,7 @@ class LoginWebAuthRequestHandler(private val builderResolver: (MethodCallRequest override fun onSuccess(credentials: Credentials) { // Success! Access token and ID token are presents val scopes = credentials.scope?.split(" ") ?: listOf() - val sdf = - SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US) - - val formattedDate = sdf.format(credentials.expiresAt) + val formattedDate = credentials.expiresAt.toInstant().toString() result.success( mapOf(