In der Anfrage fehlen die erforderlichen Authentifizierungsdaten. Erwartetes OAuth 2-Zugriffstoken, Anmeldecookie oder andere gültige Authentifizierungsdaten. Siehe https://developers.google.com/identity/ ... le-project. Problem
Als ich es gestern gesendet habe, hat es funktioniert, aber heute erhalte ich diese Fehlermeldung. Als ersten Schritt habe ich eine neue JSON-Datei in Firebase erstellt, erhalte jedoch immer noch die gleiche Fehlermeldung. Wie kann ich das beheben?
public FirebasePushService(IConfiguration configuration, ILogger logger, IWebHostEnvironment environment)
{
_logger = logger;
// Initialize Firebase Admin SDK if not already initialized
if (FirebaseApp.DefaultInstance == null)
{
var firebaseConfigPath = configuration["Firebase:ConfigPath"];
if (string.IsNullOrEmpty(firebaseConfigPath))
{
throw new ApplicationException("Firebase:ConfigPath configuration is missing");
}
// Try to find the file in multiple locations, using ContentRootPath as primary source
var possiblePaths = new[]
{
firebaseConfigPath,
Path.Combine(environment.ContentRootPath, firebaseConfigPath),
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, firebaseConfigPath),
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", firebaseConfigPath)
};
var configPath = possiblePaths.FirstOrDefault(File.Exists);
if (configPath == null)
{
_logger.LogError("Firebase configuration file not found in any of these locations: {Paths}",
string.Join(", ", possiblePaths));
throw new ApplicationException(
$"Firebase configuration file not found in any of these locations: {string.Join(", ", possiblePaths)}");
}
try
{
_logger.LogInformation("Initializing Firebase with config file: {ConfigPath}", configPath);
FirebaseApp.Create(new AppOptions()
{
Credential = GoogleCredential.FromFile(configPath)
});
_logger.LogInformation("Firebase initialized successfully");
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to initialize Firebase Admin SDK");
throw;
}
}
}
In der Anfrage fehlen die erforderlichen Authentifizierungsdaten. Erwartetes OAuth 2-Zugriffstoken, Anmeldecookie oder andere gültige Authentifizierungsdaten. Siehe https://developers.google.com/identity/sign-in/web/devconsole-project. [b]Problem[/b] Als ich es gestern gesendet habe, hat es funktioniert, aber heute erhalte ich diese Fehlermeldung. Als ersten Schritt habe ich eine neue JSON-Datei in Firebase erstellt, erhalte jedoch immer noch die gleiche Fehlermeldung. Wie kann ich das beheben? [code]public async Task SendPushNotificationAsync(string fcmToken, string title, string message) { if (string.IsNullOrWhiteSpace(fcmToken)) { _logger.LogWarning("FCM token is null or empty"); throw new ArgumentException("FCM token cannot be null or empty", nameof(fcmToken)); }
if (FirebaseApp.DefaultInstance == null) { _logger.LogError("Firebase App is not initialized. DefaultInstance is null"); throw new ApplicationException("Firebase App is not initialized"); }
var notification = new Message { Token = fcmToken, Notification = new FirebaseAdmin.Messaging.Notification { Title = title, Body = message }, Apns = new ApnsConfig() { Aps = new Aps() { Alert = new ApsAlert() { Title = title, Body = message }, Sound = "default", Badge = 1, }, } };
// Initialize Firebase Admin SDK if not already initialized if (FirebaseApp.DefaultInstance == null) { var firebaseConfigPath = configuration["Firebase:ConfigPath"];
if (string.IsNullOrEmpty(firebaseConfigPath)) { throw new ApplicationException("Firebase:ConfigPath configuration is missing"); }
// Try to find the file in multiple locations, using ContentRootPath as primary source var possiblePaths = new[] { firebaseConfigPath, Path.Combine(environment.ContentRootPath, firebaseConfigPath), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, firebaseConfigPath), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", firebaseConfigPath) };
var configPath = possiblePaths.FirstOrDefault(File.Exists);
if (configPath == null) { _logger.LogError("Firebase configuration file not found in any of these locations: {Paths}", string.Join(", ", possiblePaths)); throw new ApplicationException( $"Firebase configuration file not found in any of these locations: {string.Join(", ", possiblePaths)}"); }
Fehlermeldung:
Bei der Anfrage fehlen die erforderlichen Authentifizierungsdaten. Erwartetes OAuth 2-Zugriffstoken, Anmeldecookie oder andere gültige Authentifizierungsdaten. Siehe
Fehlermeldung:
Bei der Anfrage fehlen die erforderlichen Authentifizierungsdaten. Erwartetes OAuth 2-Zugriffstoken, Anmeldecookie oder andere gültige Authentifizierungsdaten. Siehe
Ich sende Push -Benachrichtigungen von einer .NET -Webanwendung unter Verwendung des FCM Admin .NET SDK (Firebaseadmin 3.1.0). Icon Eigenschaften, und während das Bild wie erwartet angezeigt wird,...
Ich sende Push -Benachrichtigungen von einer .NET -Webanwendung unter Verwendung des FCM Admin .NET SDK (Firebaseadmin 3.1.0). Icon Eigenschaften, und während das Bild wie erwartet angezeigt wird,...