firebaseui-web icon indicating copy to clipboard operation
firebaseui-web copied to clipboard

Bug Report: Firebase Microsoft Login Fails with auth/internal-error on New Application

Open SathishkumarG3 opened this issue 1 year ago • 0 comments

Issue Description: When attempting to log in to the new application using Microsoft login, an error occurs: firebase.service.ts:22 Error during Microsoft login: FirebaseError: Firebase: Error (auth/internal-error). The same Firebase configuration works fine with another application. However, when using a new Firebase configuration, the login process works as expected.


[REQUIRED] Environment Details:

  • Operating System version: [Windows 11]
  • Browser version: [128.0.6613.84]

[REQUIRED] Steps to Reproduce:

  1. Use the existing Firebase configuration.

  2. Attempt to log in to the new application using Microsoft login.

  3. Observe the error in the console:

    firebase.service.ts:22 Error during Microsoft login: FirebaseError: Firebase: Error (auth/internal-error).
    

Relevant Code:

import { Injectable, inject } from '@angular/core';
import { Auth, OAuthProvider, signInWithPopup, signOut } from '@angular/fire/auth';

@Injectable({
  providedIn: 'root'
})
export class FirebaseService {
  private afAuth: Auth = inject(Auth);

  constructor() { }

  // Login with Microsoft provider
  async loginWithMicrosoft() {
    try {
      const provider = new OAuthProvider('microsoft.com');
      provider.setCustomParameters({
        tenant: 'xxxxx',
      });
      const result = await signInWithPopup(this.afAuth, provider);
      return result;
    } catch (error) {
      console.error('Error during Microsoft login:', error);  // Log error for debugging
      throw error;
    }
  }

  // Logout the current user
  async logout(): Promise<void> {
    try {
      await signOut(this.afAuth);
    } catch (error) {
      console.error('Error during logout:', error);  // Log error for debugging
      throw error;
    }
  }
}

Additional Notes:

  • The same Firebase configuration works without issues in another application.
  • The error only occurs when using the existing configuration with the new application.
  • The tenantId was validated and confirmed to be correct.
  • The application is an Angular application and was run locally.
  • Switching to a new Firebase configuration resolves the login issue.

Request for Investigation: We need to understand why the existing Firebase configuration causes this error in the new application, despite working fine elsewhere. Additionally, a solution or workaround to use the existing configuration without errors would be ideal.


SathishkumarG3 avatar Aug 27 '24 14:08 SathishkumarG3