From eb010934079127a3552e60e6f07c03852d8259d5 Mon Sep 17 00:00:00 2001 From: Roger Hu Date: Mon, 24 Apr 2017 00:31:02 -0700 Subject: [PATCH] Cleanup Add constants Delete perms=delete --- .../main/java/com/codepath/oauth/OAuthBaseClient.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/codepath/oauth/OAuthBaseClient.java b/app/src/main/java/com/codepath/oauth/OAuthBaseClient.java index 1f92e4a..8add1ec 100755 --- a/app/src/main/java/com/codepath/oauth/OAuthBaseClient.java +++ b/app/src/main/java/com/codepath/oauth/OAuthBaseClient.java @@ -26,6 +26,8 @@ public abstract class OAuthBaseClient { private static final String OAUTH1_REQUEST_TOKEN = "request_token"; private static final String OAUTH1_REQUEST_TOKEN_SECRET = "request_token_secret"; + private static final String OAUTH1_VERSION = "1.0"; + private static final String OAUTH2_VERSION = "2.0"; protected static HashMap, OAuthBaseClient> instances = new HashMap, OAuthBaseClient>(); @@ -53,7 +55,7 @@ public OAuthBaseClient(Context c, BaseApi apiInstance, String consumerUrl, Strin @Override public void onReceivedRequestToken(Token requestToken, String authorizeUrl, String oAuthVersion) { if (requestToken != null) { - if (oAuthVersion == "1.0") { // store for OAuth1.0a + if (oAuthVersion == OAUTH1_VERSION) { // store for OAuth1.0a OAuth1RequestToken oAuth1RequestToken = (OAuth1RequestToken) requestToken; editor.putString(OAUTH1_REQUEST_TOKEN, oAuth1RequestToken.getToken()); editor.putString(OAUTH1_REQUEST_TOKEN_SECRET, oAuth1RequestToken.getTokenSecret()); @@ -61,7 +63,7 @@ public void onReceivedRequestToken(Token requestToken, String authorizeUrl, Stri } } // Launch the authorization URL in the browser - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(authorizeUrl + "&perms=delete")); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(authorizeUrl)); if (requestIntentFlags != -1) { intent.setFlags(requestIntentFlags); } @@ -72,7 +74,7 @@ public void onReceivedRequestToken(Token requestToken, String authorizeUrl, Stri @Override public void onReceivedAccessToken(Token accessToken, String oAuthVersion) { - if (oAuthVersion == "1.0") { + if (oAuthVersion == OAUTH1_VERSION) { OAuth1AccessToken oAuth1AccessToken = (OAuth1AccessToken) accessToken; client.setAccessToken(accessToken); @@ -80,7 +82,7 @@ public void onReceivedAccessToken(Token accessToken, String oAuthVersion) { editor.putString(OAuthConstants.TOKEN_SECRET, oAuth1AccessToken.getTokenSecret()); editor.putInt(OAuthConstants.VERSION, 1); editor.commit(); - } else if (oAuthVersion == "2.0") { + } else if (oAuthVersion == OAUTH2_VERSION) { OAuth2AccessToken oAuth2AccessToken = (OAuth2AccessToken) accessToken; client.setAccessToken(accessToken); editor.putString(OAuthConstants.TOKEN, oAuth2AccessToken.getAccessToken());