diff --git a/auth/src/main/java/com/alfresco/auth/AuthInterceptor.kt b/auth/src/main/java/com/alfresco/auth/AuthInterceptor.kt index ca3f000..f46e150 100644 --- a/auth/src/main/java/com/alfresco/auth/AuthInterceptor.kt +++ b/auth/src/main/java/com/alfresco/auth/AuthInterceptor.kt @@ -229,16 +229,6 @@ class AuthInterceptor( override fun intercept(chain: Interceptor.Chain): Response { val response = chain.proceed(AuthType.OIDC, accessToken) - // When unauthorized try to refresh -// if (response.code == HTTP_RESPONSE_401_UNAUTHORIZED) { -// val newState = refreshTokenNow() -// -// if (newState != null) { -// response.close() -// response = chain.proceed(AuthType.PKCE, newState.accessToken) -// } -// } - // If still error notify listener of failure if (response.code == HTTP_RESPONSE_401_UNAUTHORIZED) { listener?.onAuthFailure(accountId, response.request.url.toString()) diff --git a/auth/src/main/java/com/alfresco/auth/DiscoveryService.kt b/auth/src/main/java/com/alfresco/auth/DiscoveryService.kt index c93f4d5..708985d 100644 --- a/auth/src/main/java/com/alfresco/auth/DiscoveryService.kt +++ b/auth/src/main/java/com/alfresco/auth/DiscoveryService.kt @@ -28,12 +28,13 @@ class DiscoveryService( when (authConfig.authType.lowercase()) { AuthType.OIDC.value -> { - if (isOIDC(endpoint)){ + if (isOIDC(endpoint)) { return AuthType.OIDC } } + AuthType.PKCE.value -> { - if (isPkceType(endpoint)){ + if (isPkceType(endpoint)) { return AuthType.PKCE } } @@ -145,7 +146,8 @@ class DiscoveryService( return result != null } - private suspend fun isOIDC(endpoint: String): Boolean = isOIDCInstalled(endpoint) && authConfig.realm.isBlank() + private suspend fun isOIDC(endpoint: String): Boolean = + isOIDCInstalled(endpoint) && authConfig.realm.isBlank() /** * Return content service url based on [endpoint]. diff --git a/auth/src/main/java/com/alfresco/auth/pkce/PkceAuthService.kt b/auth/src/main/java/com/alfresco/auth/pkce/PkceAuthService.kt index eeac098..f1fadd0 100644 --- a/auth/src/main/java/com/alfresco/auth/pkce/PkceAuthService.kt +++ b/auth/src/main/java/com/alfresco/auth/pkce/PkceAuthService.kt @@ -131,7 +131,6 @@ internal class PkceAuthService(context: Context, authState: AuthState?, authConf val authDetails = getAppConfigOAuth2Details(uri) authDetails?.let { oauth2 -> - println("PkceAuthService.initiateLogin $authDetails") val credentials = webAuthAsync( oauth2, @@ -172,11 +171,7 @@ internal class PkceAuthService(context: Context, authState: AuthState?, authConf ): Credentials? { return try { val host = URL(oauth2.host).host - Log.d("Test OIDC -1 :: ", oauth2.clientId) - Log.d("Test OIDC 0 :: ", host) - Log.d("Test OIDC 1 :: ", activity.getString(R.string.com_auth0_scheme)) - Log.d("Test OIDC 2 :: ", oauth2.audience) - Log.d("Test OIDC 3 :: ", oauth2.scope) + val account = Auth0(oauth2.clientId, host) val credentials = WebAuthProvider.login(account) @@ -185,12 +180,10 @@ internal class PkceAuthService(context: Context, authState: AuthState?, authConf .withScope(oauth2.scope) .withAudience(oauth2.audience) .await(activity) - Log.d("Test OIDC 4 :: ", "Success: ${credentials.accessToken}") - credentials + credentials } catch (error: AuthenticationException) { val message = if (error.isCanceled) "Browser was closed" else error.getDescription() - Log.d("Test OIDC 5 :: ", "Failure: $message") null } }