am trying to install firebase authentication and it's asking for an authorization code in the cli. no matter how I check I don't see any authorization code (I have web api keys etc provided in the firebaseConfig) am I missing something obvious? here is what my steps look like in the cli:
ng add @angular/fire
Skipping installation: Package already installed
UPDATE package.json (1493 bytes)
? What features would you like to setup? Authentication
Using firebase-tools version 10.2.0
? Allow Firebase to collect CLI usage and error reporting information? No
? Enter authorization code:
I had the same problem. I solved it by following those steps :
1/ First, you have to connect your firebase account
> firebase login
2/ Next, check if the connection is alright (you need to create your project on firebase in a first place to see it in the result)
> firebase projects:list
3/ Then, you need to initialize firebase
> firebase init
4/ And now you can add the following command
> ng add @angular/fire
It's recommended to use ng add @angular/fire
, because it simplifies the setup process and ensures that everything is properly configured.
Another possibility is to skip the ng add @angular/fire
command and run npm install @angular/fire firebase
instead. Then you will need to configure the application's module file and set up the Firebase configuration in your environments files manually.
For example if you want to apply Firestore Database execute
<your/project/path>$ npm install @angular/fire firebase
<your/project/path>$ ng generate environments
then modify your app.module.ts
:
...
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
import { getFirestore, provideFirestore } from '@angular/fire/firestore';
import { environment } from '../environments/environment';
@NgModule({
declarations: [],
imports: [
...
provideFirebaseApp(() => initializeApp(environment.firebase)),
provideFirestore(() => getFirestore())
]
})
export class AppModule { }
environment.ts and environment.evelopment.ts:
export const environment = {
firebase: {
apiKey: "xxxxxxxxxxxxxxxxxx",
authDomain: "xxxxx.firebaseapp.com",
projectId: "xxxxxx",
storageBucket: "xxxx.appspot.com",
messagingSenderId: "xxxxxxx",
appId: "1:xxxxxxxx:web:xxxxxxxxx"
}
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With