-
Couldn't load subscription status.
- Fork 298
Implementing breaking API changes for FirebaseCredential API #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ng a GoogleOAuthAccessToken instance which contains expirty info in addition to the token string. Implementing all token caching at the FirebaseApp level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good. A few questions.
| /** | ||
| * Returns a Google OAuth2 access token used to authenticate with Firebase services. | ||
| * Returns a Google OAuth2 access token which can be used to authenticate with Firebase services. | ||
| * This method does not cache tokens, and therefore each invocation may trigger a token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "may trigger a token refresh" => "will fetch a fresh token."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| || !previousTask.isSuccessful() | ||
| || previousTask.getResult().isExpired())); | ||
| } | ||
| abstract GoogleOAuthAccessToken fetchToken(GoogleCredential credential) throws IOException ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space preceding the semicolon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| * @param expiryTime Time at which the token will expire (milliseconds since epoch) | ||
| * @throws IllegalArgumentException If the token is null or empty | ||
| */ | ||
| public GoogleOAuthAccessToken(String accessToken, long expiryTime) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentionally public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since FirebaseCredential interface is public we have to make this constructor public too, so that a custom implementation of the interface can create and return GoogleOauthAccessTokens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, okay. I wasn't sure if this was meant for external creation or not. It probably should have technically been in the API proposal, but I think it's probably okay. :-)
| /** | ||
| * Returns true if the token is already expired, and false otherwise. | ||
| */ | ||
| public boolean isExpired() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentionally public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We call it from FirebaseApp which is why I made it public. But on the other hand we didn't really have this method in the API proposal. If that's an issue I can just move the method to FirebaseApp. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given it wasn't in the proposal and it's just a helper, I would move it to FirebaseApp and avoid adding anything unnecessary to our public surface area .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| Tasks.await(credential.getAccessToken(false)); | ||
| Tasks.await(credential.getAccessToken(true)); | ||
| Tasks.await(credential.getAccessToken()); | ||
| Tasks.await(credential.getAccessToken()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure there's any point in doing this twice...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| Tasks.await(credential.getAccessToken(false)); | ||
| Tasks.await(credential.getAccessToken(true)); | ||
| Tasks.await(credential.getAccessToken()); | ||
| Tasks.await(credential.getAccessToken()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, drop the second call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| Addressed all suggestions made. Just one follow up question. |
| Answered. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that was a little more involved than I realized... Thanks for reworking. :-)
Returning a GoogleOAuthAccessToken instance which contains expirty info in addition to the token string. Implementing all token caching at the FirebaseApp level.