ClientError(reason=TokenNotFound, msg=Refresh token not found in the response.)
at com.kakao.sdk.auth.model.OAuthToken$a.a(OAuthToken.kt:56)
at com.kakao.sdk.auth.model.OAuthToken$a.b(OAuthToken.kt:49)
at e.i.a.a.b$d.b(AuthApiManager.kt:76)
at o.i$b$a.e(DefaultCallAdapterFactory.java:89)
at o.i$b$a.f(Unknown Source:0)
at o.b.run(Unknown Source:6)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8167)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
아래 fromResponse 에서 OAuthToken의 refreshToken 프로퍼티 넣는 부분입니다.
@Parcelize
data class OAuthToken(
val accessToken: String,
val accessTokenExpiresAt: Date,
val refreshToken: String,
val refreshTokenExpiresAt: Date,
val scopes: List<String>? = null
) : Parcelable {
companion object {
/**
* @suppress
*
* [AccessTokenResponse] 객체로부터 OAuthToken 객체 생성.
*/
fun fromResponse(response: AccessTokenResponse, oldToken: OAuthToken? = null): OAuthToken =
OAuthToken(
accessToken = response.accessToken,
accessTokenExpiresAt = Date(Date().time + 1000L * response.accessTokenExpiresIn),
refreshToken =
response.refreshToken
?: oldToken?.refreshToken
?: throw ClientError(
ClientErrorCause.TokenNotFound,
"Refresh token not found in the response."
),
refreshTokenExpiresAt =
if (response.refreshToken != null) // 체크하지 않으면, 새 토큰이 있는데 새 만료 시각이 없거나 못가져 온 경우, 앞에서는 새 토큰을 넣었는데 만료시각은 이전 값을 넣게 되어 싱크가 깨진다.
response.refreshTokenExpiresIn?.let { Date(Date().time + 1000L * it) } ?: Date()
else
oldToken?.refreshTokenExpiresAt!!,
scopes = response.scope?.split(" ") ?: oldToken?.scopes
)
}
}