@@ -82,6 +82,14 @@ public ClientCredentialsManager(String host, String apiKey,
82
82
if (timedFetch ) {
83
83
this .timer = new Timer ();
84
84
this .timer .schedule (new FetchToken (), 0 );
85
+ } else {
86
+ try {
87
+ fetchOAuthToken ();
88
+ } catch (ApiRequestException fex ) {
89
+ log .info ("CCM fetch failed: " + fex .toString ());
90
+ } catch (Exception fex ) {
91
+ log .info ("CCM fetch failed: " + fex .toString ());
92
+ }
85
93
}
86
94
}
87
95
@@ -98,13 +106,15 @@ public OAuthToken fetchOAuthToken() throws ApiRequestException {
98
106
return this .currentOAuthToken ;
99
107
}
100
108
try {
101
- // TODO: This URL should come from properties
102
- //OAuthService svc = new OAuthService("https://api-uat.mars.bf.sl.attcompute.com",
103
- OAuthService svc = new OAuthService ("https://api.att.com" ,
109
+ log .info ("ClientCredentialsManager.fetchOAuthToken: Fetching new token from " + this .host + " for client " + this .apiKey );
110
+ OAuthService svc = new OAuthService (this .host ,
104
111
this .apiKey , this .apiSecret );
105
112
this .currentOAuthToken = svc .getToken (this .scope );
113
+ log .info ("ClientCredentialsManager.fetchOAuthToken successful: " +
114
+ currentOAuthToken .getAccessToken ());
106
115
return this .currentOAuthToken ;
107
116
} catch (RESTException ex ) {
117
+ log .info ("ClientCredentialsManager.fetchOAuthToken failed. " + ex .toString ());
108
118
throw new ApiRequestException ("could not get oauth token" , 403 ,
109
119
"{\" error\" :\" could not get oauth token\" }" , ex );
110
120
}
@@ -215,7 +225,7 @@ class FetchToken extends TimerTask {
215
225
public void run () {
216
226
try {
217
227
fetchOAuthToken ();
218
- fetchToken (false );
228
+ // fetchToken(false);
219
229
220
230
} catch (Exception e ) {
221
231
log .severe ("Could not fetch auth token" + e .getMessage ());
@@ -236,5 +246,6 @@ public void run() {
236
246
public String getCurrentToken () {
237
247
return currentAuthToken ;
238
248
}
249
+
239
250
240
- }
251
+ }
0 commit comments