@@ -9,6 +9,8 @@ deferred class
99inherit
1010 ARGUMENTS
1111
12+ LOGGABLE
13+
1214
1315feature {NONE } -- Initialization
1416
@@ -20,13 +22,9 @@ feature {NONE} -- Initialization
2022 create last_token .make_empty
2123 get_token
2224 if last_token .token .is_empty then
23- debug
24- print (" There is something wwrong" )
25- end
25+ logger .write_warning (" retrieve_access_token-> There is something wrong token is empty" )
2626 else
27- debug
28- print (" Let's play with the API" )
29- end
27+ logger .write_debug (" retrieve_access_token-> Let's play with the API, token seems ok:" + last_token .token )
3028 end
3129 end
3230
@@ -38,7 +36,6 @@ feature {NONE} -- Initialization
3836 l_date_now : DATE_TIME
3937 l_diff : INTEGER_ 64
4038 do
41-
4239 create {PLAIN_TEXT_FILE } file .make_with_name (" token.access" )
4340 if file .exists then
4441 file .open_read
@@ -54,10 +51,11 @@ feature {NONE} -- Initialization
5451 else
5552 create token .make_empty
5653 end
54+ logger .write_debug (" get_token-> token got from file" )
5755 file .close
5856 else
5957 token := get_token_from_url
60-
58+ logger . write_debug ( " get_token-> token got from url " )
6159 end
6260 last_token := token
6361 end
@@ -72,26 +70,25 @@ feature {NONE} -- Initialization
7270 api_service : OAUTH_SERVICE_I
7371 file : FILE
7472 do
75-
7673 check
7774 attached api_key as l_api_key
7875 attached api_secret as l_api_secret
7976 then
80- print (" get_token_from_url-> api_key:'" + l_api_key + " ' secret:'" + l_api_secret + " '" )
77+ logger . write_debug (" get_token_from_url-> api_key:'" + l_api_key + " ' secret:'" + l_api_secret + " '" )
8178 create Result .make_empty
8279 create config .make_default (l_api_key , l_api_secret )
83- config .set_callback (" urn:ietf:wg:oauth:2.0:oob" )
80+ config .set_callback (" urn:ietf:wg:oauth:2.0:oob" )
8481 config .set_scope (" https://www.googleapis.com/auth/spreadsheets" )
8582 create google
8683 api_service := google .create_service (config )
87- print (" %N===Google OAuth Workflow ===%N" )
84+ logger . write_debug (" %N===Google OAuth Workflow ===%N" )
8885
8986 -- Obtain the Authorization URL
90- print (" %NFetching the Authorization URL..." );
87+ logger . write_debug (" %NFetching the Authorization URL..." );
9188 if attached api_service .authorization_url (empty_token ) as lauthorization_url then
92- print (" %NGot the Authorization URL!%N" );
93- print (" %NNow go and authorize here:%N" );
94- print (lauthorization_url );
89+ logger . write_debug (" %NGot the Authorization URL!%N" );
90+ logger . write_debug (" %NNow go and authorize here:%N" );
91+ print (" get_token_from_url-> authorization_url: " + lauthorization_url );
9592 print (" %NAnd paste the authorization code here%N" );
9693 io .read_line
9794 end
@@ -126,7 +123,7 @@ feature {NONE} -- Initialization
126123 attached api_key as l_api_key
127124 attached api_secret as l_api_secret
128125 then
129- print (" refresh_access_token-> api_key:'" + l_api_key + " ' secret:'" + l_api_secret + " '" )
126+ logger . write_debug (" refresh_access_token-> api_key:'" + l_api_key + " ' secret:'" + l_api_secret + " '" )
130127 create Result .make_empty
131128 create google
132129 create request .make (" POST" , google .access_token_endpoint )
@@ -245,5 +242,5 @@ feature {NONE} -- Implementation
245242 api_secret : detachable STRING
246243 empty_token : detachable OAUTH_TOKEN
247244
248-
245+
249246end
0 commit comments