Skip to content

Commit de78084

Browse files
committed
rename to token client
1 parent 7a03f9b commit de78084

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

app/src/main/java/com/codepath/oauth/OAuthBaseClient.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
public abstract class OAuthBaseClient {
1818
protected String baseUrl;
1919
protected Context context;
20-
protected OAuthTokenClient client;
20+
protected OAuthTokenClient tokenClient;
2121
protected SharedPreferences prefs;
2222
protected SharedPreferences.Editor editor;
2323
protected OAuthAccessHandler accessHandler;
@@ -48,7 +48,7 @@ public static OAuthBaseClient getInstance(Class<? extends OAuthBaseClient> klass
4848
public OAuthBaseClient(Context c, BaseApi apiInstance, String consumerUrl, String consumerKey, String consumerSecret, String callbackUrl) {
4949
this.baseUrl = consumerUrl;
5050
this.callbackUrl = callbackUrl;
51-
client = new OAuthTokenClient(apiInstance, consumerKey,
51+
tokenClient = new OAuthTokenClient(apiInstance, consumerKey,
5252
consumerSecret, callbackUrl, new OAuthTokenClient.OAuthTokenHandler() {
5353

5454
// Store request token and launch the authorization URL in the browser
@@ -70,21 +70,21 @@ public void onReceivedRequestToken(Token requestToken, String authorizeUrl, Stri
7070
OAuthBaseClient.this.context.startActivity(intent);
7171
}
7272

73-
// Store the access token in preferences, set the token in the client and fire the success callback
73+
// Store the access token in preferences, set the token in the tokenClient and fire the success callback
7474
@Override
7575
public void onReceivedAccessToken(Token accessToken, String oAuthVersion) {
7676

7777
if (oAuthVersion == OAUTH1_VERSION) {
7878
OAuth1AccessToken oAuth1AccessToken = (OAuth1AccessToken) accessToken;
7979

80-
client.setAccessToken(accessToken);
80+
tokenClient.setAccessToken(accessToken);
8181
editor.putString(OAuthConstants.TOKEN, oAuth1AccessToken.getToken());
8282
editor.putString(OAuthConstants.TOKEN_SECRET, oAuth1AccessToken.getTokenSecret());
8383
editor.putInt(OAuthConstants.VERSION, 1);
8484
editor.commit();
8585
} else if (oAuthVersion == OAUTH2_VERSION) {
8686
OAuth2AccessToken oAuth2AccessToken = (OAuth2AccessToken) accessToken;
87-
client.setAccessToken(accessToken);
87+
tokenClient.setAccessToken(accessToken);
8888
editor.putString(OAuthConstants.TOKEN, oAuth2AccessToken.getAccessToken());
8989
editor.putString(OAuthConstants.SCOPE, oAuth2AccessToken.getScope());
9090
editor.putString(OAuthConstants.REFRESH_TOKEN, oAuth2AccessToken.getRefreshToken());
@@ -106,24 +106,24 @@ public void onFailure(Exception e) {
106106
// Store preferences namespaced by the class and consumer key used
107107
this.prefs = this.context.getSharedPreferences("OAuth_" + apiInstance.getClass().getSimpleName() + "_" + consumerKey, 0);
108108
this.editor = this.prefs.edit();
109-
// Set access token in the client if already stored in preferences
109+
// Set access token in the tokenClient if already stored in preferences
110110
if (this.checkAccessToken() != null) {
111-
client.setAccessToken(this.checkAccessToken());
111+
tokenClient.setAccessToken(this.checkAccessToken());
112112
}
113113
}
114114

115115
// Fetches a request token and retrieve and authorization url
116116
// Should open a browser in onReceivedRequestToken once the url has been received
117117
public void connect() {
118-
client.fetchRequestToken();
118+
tokenClient.fetchRequestToken();
119119
}
120120

121121
// Retrieves access token given authorization url
122122
public void authorize(Uri uri, OAuthAccessHandler handler) {
123123
this.accessHandler = handler;
124124
if (checkAccessToken() == null && uri != null) {
125125
// TODO: check UriServiceCallback with intent:// scheme
126-
client.fetchAccessToken(getOAuth1RequestToken(), uri);
126+
tokenClient.fetchAccessToken(getOAuth1RequestToken(), uri);
127127

128128
} else if (checkAccessToken() != null) { // already have access token
129129
this.accessHandler.onLoginSuccess();
@@ -143,8 +143,8 @@ public Token checkAccessToken() {
143143
return null;
144144
}
145145

146-
protected OAuthTokenClient getClient() {
147-
return client;
146+
protected OAuthTokenClient getTokenClient() {
147+
return tokenClient;
148148
}
149149

150150
// Returns the request token stored during the request token phase
@@ -165,17 +165,17 @@ protected String getApiUrl(String path) {
165165

166166
// Removes the access tokens (for signing out)
167167
public void clearAccessToken() {
168-
client.setAccessToken(null);
168+
tokenClient.setAccessToken(null);
169169
editor.remove(OAuthConstants.TOKEN);
170170
editor.remove(OAuthConstants.TOKEN_SECRET);
171171
editor.remove(OAuthConstants.REFRESH_TOKEN);
172172
editor.remove(OAuthConstants.SCOPE);
173173
editor.commit();
174174
}
175175

176-
// Returns true if the client is authenticated; false otherwise.
176+
// Returns true if the tokenClient is authenticated; false otherwise.
177177
public boolean isAuthenticated() {
178-
return client.getAccessToken() != null;
178+
return tokenClient.getAccessToken() != null;
179179
}
180180

181181
// Sets the flags used when launching browser to authenticate through OAuth

0 commit comments

Comments
 (0)