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

Commit dd1ff4ef authored by Alexandre Roux's avatar Alexandre Roux Committed by Romain Hunault
Browse files

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

always refresh when asked since it happens when an app using the api encounters autentification issues + return null when sending an async response, as the api describes

(cherry picked from commit 99ff2f4a)
parent 020fa428
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) {
                if (authState.needsTokenRefresh || true) { //keep true for now since it is refreshed only when invalidated, so when having an issue
                    val tokenRequest = authState.createTokenRefreshRequest()

                    AuthorizationService(context).performTokenRequest(tokenRequest) { tokenResponse, ex ->
@@ -136,6 +136,7 @@ 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()
@@ -154,4 +155,3 @@ class GoogleAccountAuthenticatorService : Service(), OnAccountsUpdateListener {

    }
}