From aa717b3e7bfc616a5570238d3f46511b77ab7e2a Mon Sep 17 00:00:00 2001 From: davigonz Date: Mon, 31 Jul 2017 10:47:20 +0200 Subject: [PATCH] Use proper grant type to get new access token using refresh token --- .../oauth/OAuth2GetRefreshedAccessTokenOperation.java | 3 +++ .../common/network/authentication/oauth/OAuth2GrantType.java | 1 + 2 files changed, 4 insertions(+) diff --git a/src/com/owncloud/android/lib/common/network/authentication/oauth/OAuth2GetRefreshedAccessTokenOperation.java b/src/com/owncloud/android/lib/common/network/authentication/oauth/OAuth2GetRefreshedAccessTokenOperation.java index c1257b82..ec95d628 100644 --- a/src/com/owncloud/android/lib/common/network/authentication/oauth/OAuth2GetRefreshedAccessTokenOperation.java +++ b/src/com/owncloud/android/lib/common/network/authentication/oauth/OAuth2GetRefreshedAccessTokenOperation.java @@ -87,13 +87,16 @@ public class OAuth2GetRefreshedAccessTokenOperation extends RemoteOperation { mClientId, mClientSecret ); + OwnCloudCredentials oldCredentials = switchClientCredentials(oauthCredentials); client.executeMethod(postMethod); + switchClientCredentials(oldCredentials); String response = postMethod.getResponseBodyAsString(); Log_OC.d(TAG, "OAUTH2: raw response from POST TOKEN: " + response); + if (response != null && response.length() > 0) { JSONObject tokenJson = new JSONObject(response); parseNewAccessTokenResult(tokenJson); diff --git a/src/com/owncloud/android/lib/common/network/authentication/oauth/OAuth2GrantType.java b/src/com/owncloud/android/lib/common/network/authentication/oauth/OAuth2GrantType.java index 26c53dba..fdf98bcf 100644 --- a/src/com/owncloud/android/lib/common/network/authentication/oauth/OAuth2GrantType.java +++ b/src/com/owncloud/android/lib/common/network/authentication/oauth/OAuth2GrantType.java @@ -28,6 +28,7 @@ package com.owncloud.android.lib.common.network.authentication.oauth; public enum OAuth2GrantType { AUTHORIZATION_CODE("authorization_code"), + REFRESH_TOKEN("refresh_token"), IMPLICIT("implicit"), PASSWORD("password"), CLIENT_CREDENTIAL("client_credentials");