Skip to content
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

AppCheck token(forcingRefresh: true) returns cached token if token(forcingRefresh: false) in progress #42

Open
andrewheard opened this issue Nov 8, 2023 · 0 comments · Fixed by #43

Comments

@andrewheard
Copy link
Collaborator

Calls to token(forcingRefresh:) with forcingRefresh: true may return a cached token if a call is already in progress where forcingRefresh: false. This may be as simple as adding || forcingRefresh to if (self.ongoingRetrieveOrRefreshTokenPromise == nil) (see below) but needs testing.

if (self.ongoingRetrieveOrRefreshTokenPromise == nil) {
// Kick off a new operation only when there is not an ongoing one.
self.ongoingRetrieveOrRefreshTokenPromise =
[self createRetrieveOrRefreshTokenPromiseForcingRefresh:forcingRefresh]
// Release the ongoing operation promise on completion.
.then(^GACAppCheckToken *(GACAppCheckToken *token) {
self.ongoingRetrieveOrRefreshTokenPromise = nil;
return token;
})
.recover(^NSError *(NSError *error) {
self.ongoingRetrieveOrRefreshTokenPromise = nil;
return error;
});
}
return self.ongoingRetrieveOrRefreshTokenPromise;

Note: this issue isn't new (already exists in FirebaseAppCheck 10.17.0) but the code has moved to this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant