Description
Version info
Angular: 15.2.9
Firebase: 12.0.0 firebase --version
AngularFire: 7.5.0
Node: 16.20.0
OS: Manjaro Linux KDE Plasma 5.27.5
How to reproduce these conditions
Steps to set up and reproduce
Fresh project with @angular/fire
adding firestore and auth in app.module.ts as initial setup.
Then adding app-check after the initializeApp as shown in code:
(app.module.ts)
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { LayoutModule } from '@angular/cdk/layout' ;
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';
import { ReCaptchaV3Provider, initializeAppCheck, provideAppCheck } from '@angular/fire/app-check' ;
import { environment } from '../environments/environment';
import { provideAuth,getAuth, connectAuthEmulator } from '@angular/fire/auth';
import { provideFirestore,getFirestore, Firestore, initializeFirestore } from '@angular/fire/firestore';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
provideFirebaseApp(() => initializeApp(environment.firebase)),
provideAppCheck( () => initializeAppCheck(undefined, {
provider: new ReCaptchaV3Provider(environment.recaptchaV3SiteKey),
isTokenAutoRefreshEnabled: true
})),
provideAuth(() => {
const auth = getAuth() ;
if (environment.useEmulators){
connectAuthEmulator(auth, 'http://localhost:9099', {
disableWarnings: true
}) ;
}
return auth ;
}),
provideFirestore(() => {
let firestore: Firestore ;
if (environment.useEmulators){
firestore = initializeFirestore(getApp(), {
experimentalForceLongPolling: true
}) ;
}
else{
firestore = getFirestore() ;
}
return firestore ;
}),
BrowserAnimationsModule,
LayoutModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
On using ng serve
gives a debug token which i've added in the app-check section of firebase console. But the error 403 is still persisting with response.
{
"error": {
"code": 403,
"message": "Invalid API key for project ID: demo-project",
"status": "PERMISSION_DENIED"
}
}
As, shown in screenshot below.
Also, noticed that this.appcheck
gives my app credentials but here on ng serve
it shows demo-project as projectId but when i make production build log gives original projectId that i've setup but with different debug token each time with error having "App attestation failed."
Expected behavior
It should stop giving 403 error