|
|
@ -98,8 +98,13 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory |
|
|
|
return if (state.refreshToken != null) { |
|
|
|
return if (state.refreshToken != null) { |
|
|
|
val refreshRequest = state.createTokenRefreshRequest() |
|
|
|
val refreshRequest = state.createTokenRefreshRequest() |
|
|
|
val auth = ClientSecretPost(state.clientSecret) |
|
|
|
val auth = ClientSecretPost(state.clientSecret) |
|
|
|
|
|
|
|
val refreshService = service(context) |
|
|
|
runBlocking { |
|
|
|
runBlocking { |
|
|
|
service(context).performTokenRequest(refreshRequest, auth) { response, e -> |
|
|
|
refreshService.performTokenRequest(refreshRequest, auth) { response, e -> |
|
|
|
|
|
|
|
if (e != null) { |
|
|
|
|
|
|
|
Log.e("OAuth", "performTokenRequest failed: ${e}") |
|
|
|
|
|
|
|
Log.e("OAuth", Log.getStackTraceString(e)) |
|
|
|
|
|
|
|
} else { |
|
|
|
state.apply { |
|
|
|
state.apply { |
|
|
|
Log.i("OAuth", "applying new authState") |
|
|
|
Log.i("OAuth", "applying new authState") |
|
|
|
update(response, e) |
|
|
|
update(response, e) |
|
|
@ -107,6 +112,8 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
refreshService.dispose() |
|
|
|
true |
|
|
|
true |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
false |
|
|
|
false |
|
|
@ -202,17 +209,23 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory |
|
|
|
|
|
|
|
|
|
|
|
AuthorizationResponse.fromIntent(authorization)?.let { |
|
|
|
AuthorizationResponse.fromIntent(authorization)?.let { |
|
|
|
val auth = ClientSecretPost(state().clientSecret) |
|
|
|
val auth = ClientSecretPost(state().clientSecret) |
|
|
|
|
|
|
|
val requestService = service(context) |
|
|
|
|
|
|
|
|
|
|
|
service(context).performTokenRequest(it.createTokenExchangeRequest(), auth) { response, e -> |
|
|
|
requestService.performTokenRequest(it.createTokenExchangeRequest(), auth) { response, e -> |
|
|
|
state |
|
|
|
if (e != null) { |
|
|
|
.apply { |
|
|
|
Log.e("FFA", "performTokenRequest failed: ${e}") |
|
|
|
|
|
|
|
Log.e("FFA", Log.getStackTraceString(e)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
state.apply { |
|
|
|
update(response, e) |
|
|
|
update(response, e) |
|
|
|
save() |
|
|
|
save() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (response != null) success() |
|
|
|
if (response != null) success() |
|
|
|
else Log.e("FFA", "performTokenRequest() not successful") |
|
|
|
else Log.e("FFA", "performTokenRequest() not successful") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
requestService.dispose() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|