firebase / firebase-admin-dotnet

Firebase Admin .NET SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
370 stars 132 forks source link

SubscribeToTopic() results in 401 #439

Open metodiobetsanov opened 3 days ago

metodiobetsanov commented 3 days ago

[READ] Step 1: Are you in the right place?

[REQUIRED] Step 2: Describe your environment

[REQUIRED] Step 3: Describe the problem

We have 2 projects on GCP, project A is used to host workloads on GKE, and project B is set with Firebase We have a service/api that will handle notifications requests from client apps and will send them to FCM. The authentication is done via ACD and workload federation, the SAs are given all permissions required. We are able to send notification and data messages to the devices, but when we send a subscribe to topic request we get 401

Steps to reproduce:

  1. intiialize the default instace for the app,
  2. get the messaging service
  3. use SubscribeToTopicAsync to subscribe a device/s to topic

Relevant Code:

FirebaseApp app = FirebaseApp.Create(
new AppOptions
    {
        ProjectId = firebase_project_id,
        Credential = GoogleCredential.GetApplicationDefault(),
    });
var firebaseMessaging= FirebaseMessaging.GetMessaging(app);

TopicManagementResponse response = firebaseMessaging
                                                    .SubscribeToTopicAsync(new[] { "device_token" }, "test_topic")
                                                    .GetAwaiter()
                                                    .GetResult();
google-oss-bot commented 3 days ago

I found a few problems with this issue: