I have Angular Ionic cap. project which uses firebase for authentication. For web client all good but when I run on emulators and real devices, getting below error:
{"url":"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=YOUR_API_KEY","data":{"error":{"message":"API key not valid. Please pass a valid API key.","details":[{"@type":"type.googleapis.com/google.rpc.ErrorInfo","metadata":..
Here is my app module how to import:
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule,
IonicModule.forRoot(),
AppRoutingModule,
BrowserAnimationsModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFireAuthModule],
providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
bootstrap: [AppComponent],
})
export class AppModule {}
here my auth service:
constructor(private afAuth: AngularFireAuth,
private router: Router,
private alertController: AlertController) { }
signIn(email: string, password: string) {
return this.afAuth
.signInWithEmailAndPassword(email, password)
.then((result) => {
const user = result.user;
if (user) {
this.router.navigateByUrl('/tabs');
}
})
.catch((error) => {
this.router.navigateByUrl('/tabs');
});
}
And here my environemnt.ts:
export const environment = {
production: false,
firebaseConfig: {
apiKey: "xx",
authDomain: "xx",
projectId: "xx",
storageBucket: "xx",
messagingSenderId: "xx",
appId: "xx",
measurementId: "xx"
}
};
Relaed versions from my package json:
"@ionic/angular": "^8.0.0",
"@angular/fire": "^18.0.1",
"firebase": "^10.12.5",
"@capacitor/ios": "6.1.1",
As I mentioned abowe, all works perfect in web. Do I missing smt very important? Many Thanks for helps!