Skip to content

Commit d440bc6

Browse files
Benjamin Schwertfegerslisson
authored andcommitted
fix(mps-sync-plugin): use refresh token, if access token is expired
1 parent 4b29797 commit d440bc6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

model-client/src/jvmMain/kotlin/org/modelix/model/oauth/ModelixAuthClient.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@ actual class ModelixAuthClient {
7878
}
7979

8080
suspend fun getAndMaybeRefreshTokens(): Credential? {
81-
return getTokens()?.refreshIfExpired()
81+
return lastCredentials?.refreshIfExpired()
8282
}
8383

8484
suspend fun refreshTokensOrReauthorize(config: OAuthConfig): Credential? {
85-
return getTokens()?.alwaysRefresh() ?: authorize(config)
85+
return lastCredentials?.alwaysRefresh() ?: authorize(config)
8686
}
8787

8888
suspend fun authorize(config: OAuthConfig): Credential? {
@@ -114,6 +114,7 @@ actual class ModelixAuthClient {
114114
return@withContext tokens
115115
} catch (ex: SocketException) {
116116
LOG.info("Port $port already in use. Trying next one.")
117+
LOG.debug(ex)
117118
}
118119
}
119120
throw IllegalStateException("Couldn't find an available port for the redirect URL")

0 commit comments

Comments
 (0)