Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6047900 authored by Romain Hunault's avatar Romain Hunault 💻
Browse files

Revert "always refresh when asked since it happens when an app using the api..."

This reverts commit dd1ff4ef
parent 2c15c655
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -119,12 +119,12 @@ class GoogleAccountAuthenticatorService : Service(), OnAccountsUpdateListener {
        override fun getAuthTokenLabel(p0: String?) = null
        override fun confirmCredentials(p0: AccountAuthenticatorResponse?, p1: Account?, p2: Bundle?) = null
        override fun updateCredentials(p0: AccountAuthenticatorResponse?, p1: Account?, p2: String?, p3: Bundle?) = null
        override fun getAuthToken(response: AccountAuthenticatorResponse?, account: Account?, authTokenType: String?, options: Bundle?): Bundle? {
	override fun getAuthToken(response: AccountAuthenticatorResponse?, account: Account?, authTokenType: String?, options: Bundle?): Bundle {
            val accountManager = AccountManager.get(context)
            val authState = AuthState.jsonDeserialize(accountManager.getUserData(account, AccountSettings.KEY_AUTH_STATE))

            if (authState != null) {
                if (authState.needsTokenRefresh || true) { //keep true for now since it is refreshed only when invalidated, so when having an issue
                if (authState.needsTokenRefresh) {
                    val tokenRequest = authState.createTokenRefreshRequest()

                    AuthorizationService(context).performTokenRequest(tokenRequest) { tokenResponse, ex ->
@@ -136,7 +136,6 @@ class GoogleAccountAuthenticatorService : Service(), OnAccountsUpdateListener {
                                result.putString(AccountManager.KEY_AUTHTOKEN, authState.accessToken)
                                response?.onResult(result)
                            }
                    return null; //should return null when returned via an async response
                }
                else {
                    val result = Bundle()
@@ -155,3 +154,4 @@ class GoogleAccountAuthenticatorService : Service(), OnAccountsUpdateListener {

    }
}