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

Added a new API to allow a custom debug secret #6742

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
public class DebugAppCheckProviderFactory implements AppCheckProviderFactory {

private static final DebugAppCheckProviderFactory instance = new DebugAppCheckProviderFactory();
private static String _debugSecret;

private DebugAppCheckProviderFactory() {}

Expand All @@ -40,11 +41,20 @@ private DebugAppCheckProviderFactory() {}
public static DebugAppCheckProviderFactory getInstance() {
return instance;
}
@NonNull
public static DebugAppCheckProviderFactory getInstance(String debugSecret) {
_debugSecret = debugSecret;
return instance;
}

@NonNull
@Override
@SuppressWarnings("FirebaseUseExplicitDependencies")
public AppCheckProvider create(@NonNull FirebaseApp firebaseApp) {
return firebaseApp.get(DebugAppCheckProvider.class);
DebugAppCheckProvider debugAppCheckProvider = firebaseApp.get(DebugAppCheckProvider.class);
if (_debugSecret != null && !_debugSecret.isEmpty()) {
debugAppCheckProvider.setDebugSecret(_debugSecret);
}
return debugAppCheckProvider;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ public DebugAppCheckProvider(
this.debugSecretTask = Tasks.forResult(debugSecret);
}

@VisibleForTesting

Choose a reason for hiding this comment

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

it would be nice to have this not just visible for testing but for normal usage too :) right now distributing the apk manually i have to get a lot of peoples keys to be able to use vertex AI.

@NonNull
void setDebugSecret(@NonNull String debugSecret) {

StorageHelper storageHelper =
new StorageHelper(
firebaseApp.getApplicationContext(), firebaseApp.getPersistenceKey());
storageHelper.saveDebugSecret(debugSecret);
}

@VisibleForTesting
@NonNull
static Task<String> determineDebugSecret(
Expand Down