Search in sources :

Example 1 with FirebaseAuthCredentialsProvider

use of com.google.firebase.firestore.auth.FirebaseAuthCredentialsProvider in project firebase-android-sdk by firebase.

the class FirebaseFirestore method newInstance.

@NonNull
static FirebaseFirestore newInstance(@NonNull Context context, @NonNull FirebaseApp app, @NonNull Deferred<InternalAuthProvider> deferredAuthProvider, @NonNull Deferred<InternalAppCheckTokenProvider> deferredAppCheckTokenProvider, @NonNull String database, @NonNull InstanceRegistry instanceRegistry, @Nullable GrpcMetadataProvider metadataProvider) {
    String projectId = app.getOptions().getProjectId();
    if (projectId == null) {
        throw new IllegalArgumentException("FirebaseOptions.getProjectId() cannot be null");
    }
    DatabaseId databaseId = DatabaseId.forDatabase(projectId, database);
    AsyncQueue queue = new AsyncQueue();
    CredentialsProvider<User> authProvider = new FirebaseAuthCredentialsProvider(deferredAuthProvider);
    CredentialsProvider<String> appCheckProvider = new FirebaseAppCheckTokenProvider(deferredAppCheckTokenProvider);
    // Firestore uses a different database for each app name. Note that we don't use
    // app.getPersistenceKey() here because it includes the application ID which is related
    // to the project ID. We already include the project ID when resolving the database,
    // so there is no need to include it in the persistence key.
    String persistenceKey = app.getName();
    FirebaseFirestore firestore = new FirebaseFirestore(context, databaseId, persistenceKey, authProvider, appCheckProvider, queue, app, instanceRegistry, metadataProvider);
    return firestore;
}
Also used : User(com.google.firebase.firestore.auth.User) FirebaseAppCheckTokenProvider(com.google.firebase.firestore.auth.FirebaseAppCheckTokenProvider) DatabaseId(com.google.firebase.firestore.model.DatabaseId) AsyncQueue(com.google.firebase.firestore.util.AsyncQueue) FirebaseAuthCredentialsProvider(com.google.firebase.firestore.auth.FirebaseAuthCredentialsProvider) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)1 FirebaseAppCheckTokenProvider (com.google.firebase.firestore.auth.FirebaseAppCheckTokenProvider)1 FirebaseAuthCredentialsProvider (com.google.firebase.firestore.auth.FirebaseAuthCredentialsProvider)1 User (com.google.firebase.firestore.auth.User)1 DatabaseId (com.google.firebase.firestore.model.DatabaseId)1 AsyncQueue (com.google.firebase.firestore.util.AsyncQueue)1