19
19
#import " FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuth.h"
20
20
21
21
#import " FirebaseAuth/Sources/Auth/FIRAuthSerialTaskQueue.h"
22
+ #import " FirebaseAuth/Sources/Auth/FIRAuth_Internal.h"
22
23
#import " FirebaseAuth/Sources/Backend/FIRAuthBackend.h"
23
24
#import " FirebaseAuth/Sources/Backend/FIRAuthRequestConfiguration.h"
24
25
#import " FirebaseAuth/Sources/Backend/RPC/FIRSecureTokenRequest.h"
25
26
#import " FirebaseAuth/Sources/Backend/RPC/FIRSecureTokenResponse.h"
26
27
28
+ #import " FirebaseCore/Sources/Private/FirebaseCoreInternal.h"
29
+
27
30
NS_ASSUME_NONNULL_BEGIN
28
31
29
32
/* * @var kAPIKeyCodingKey
@@ -111,6 +114,7 @@ - (void)fetchAccessTokenForcingRefresh:(BOOL)forceRefresh
111
114
complete ();
112
115
callback (self->_accessToken , nil , NO );
113
116
} else {
117
+ FIRLogDebug (kFIRLoggerAuth , @" I-AUT000017" , @" Fetching new token from backend." );
114
118
[self requestAccessToken: ^(NSString *_Nullable token, NSError *_Nullable error,
115
119
BOOL tokenUpdated) {
116
120
complete ();
@@ -189,6 +193,9 @@ - (void)requestAccessToken:(FIRFetchAccessTokenCallback)callback {
189
193
self->_accessToken = [newAccessToken copy ];
190
194
self->_accessTokenExpirationDate = response.approximateExpirationDate ;
191
195
tokenUpdated = YES ;
196
+ FIRLogDebug (kFIRLoggerAuth , @" I-AUT000017" ,
197
+ @" Updated access token. Estimated expiration date: %@ , current date: %@ " ,
198
+ self->_accessTokenExpirationDate , [NSDate date ]);
192
199
}
193
200
NSString *newRefreshToken = response.refreshToken ;
194
201
if (newRefreshToken.length && ![newRefreshToken isEqualToString: self ->_refreshToken]) {
@@ -200,7 +207,19 @@ - (void)requestAccessToken:(FIRFetchAccessTokenCallback)callback {
200
207
}
201
208
202
209
- (BOOL )hasValidAccessToken {
203
- return _accessToken && [_accessTokenExpirationDate timeIntervalSinceNow ] > kFiveMinutes ;
210
+ BOOL hasValidAccessToken =
211
+ _accessToken && [_accessTokenExpirationDate timeIntervalSinceNow ] > kFiveMinutes ;
212
+ if (hasValidAccessToken) {
213
+ FIRLogDebug (kFIRLoggerAuth , @" I-AUT000017" ,
214
+ @" Has valid access token. Estimated expiration date: %@ , current date: %@ " ,
215
+ _accessTokenExpirationDate, [NSDate date ]);
216
+ } else {
217
+ FIRLogDebug (
218
+ kFIRLoggerAuth , @" I-AUT000017" ,
219
+ @" Does not have valid access token. Estimated expiration date: %@ , current date: %@ " ,
220
+ _accessTokenExpirationDate, [NSDate date ]);
221
+ }
222
+ return hasValidAccessToken;
204
223
}
205
224
206
225
@end
0 commit comments