Skip to content

Conversation

@hiranya911
Copy link
Contributor

Returning a GoogleOAuthAccessToken instance which contains expirty info in addition to the token string. Implementing all token caching at the FirebaseApp level.

…ng a GoogleOAuthAccessToken instance which contains expirty info in addition to the token string. Implementing all token caching at the FirebaseApp level.
Copy link

@mikelehen mikelehen left a 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

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."

Copy link
Contributor Author

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 ;

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

Copy link
Contributor Author

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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentionally public?

Copy link
Contributor Author

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.

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() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentionally public?

Copy link
Contributor Author

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?

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 .

Copy link
Contributor Author

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());

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...

Copy link
Contributor Author

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());

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@mikelehen mikelehen assigned hiranya911 and unassigned mikelehen Apr 24, 2017
@hiranya911
Copy link
Contributor Author

Addressed all suggestions made. Just one follow up question.

@hiranya911 hiranya911 assigned mikelehen and unassigned hiranya911 Apr 24, 2017
@mikelehen mikelehen assigned hiranya911 and unassigned mikelehen Apr 24, 2017
@mikelehen
Copy link

Answered. :)

@hiranya911 hiranya911 assigned mikelehen and unassigned hiranya911 Apr 25, 2017
Copy link

@mikelehen mikelehen left a 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. :-)

@hiranya911 hiranya911 merged commit 6cd3540 into io2017 Apr 25, 2017
@hiranya911 hiranya911 deleted the hkj-refactor-credentials branch April 25, 2017 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants