Authentication Error

Đang mở
#503 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp, firebase
Lĩnh vực
authentication, backend

Hướng nghiên cứu

Bắt đầu với lệnh gọi FirebaseClient.cs ở dòng 67 và lần theo nó qua FirebaseMessaging.SendAsync và ErrorHandlingHttpClient.SendAndReadAsync. So sánh thiết lập credential của FirebaseApp với kiểm tra access-token của scoped credential được nêu trong issue. Hoàn tất có nghĩa là xác định được lý do request thiếu xác thực và xác nhận request messaging đã sửa hoạt động thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

FirebaseAdmin: 3.4.0
.NET Version: 10

My firebase messaging stopped working all suddenly, no code changes, Firebase Messaging API enabled, Service Account credential is active.

Setup code in my service

var credential = CredentialFactory.FromFile<ServiceAccountCredential>(options.Value.FIREBASE_ADMIN_FILE);
_app = FirebaseApp.Create(new AppOptions()
{
    Credential = credential.ToGoogleCredential(),
});
_messaging = FirebaseMessaging.GetMessaging(_app);

When attempting to send a message, I now get the errors below:

FirebaseAdmin.Messaging.FirebaseMessagingException: Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.

at FirebaseAdmin.Util.ErrorHandlingHttpClient`1.SendAndReadAsync(HttpRequestMessage request, CancellationToken cancellationToken)

at FirebaseAdmin.Util.ErrorHandlingHttpClient`1.SendAndDeserializeAsync[TResult](HttpRequestMessage request, CancellationToken cancellationToken)

at FirebaseAdmin.Messaging.FirebaseMessagingClient.SendAsync(Message message, Boolean dryRun, CancellationToken cancellationToken)

at FirebaseAdmin.Messaging.FirebaseMessaging.SendAsync(Message message, Boolean dryRun, CancellationToken cancellationToken)

at FirebaseAdmin.Messaging.FirebaseMessaging.SendAsync(Message message, CancellationToken cancellationToken)

at NoWow.EmailService.FirebaseClient.NotifyAsync(Guid userId, String token, String title, String body, Dictionary`2 data, CancellationToken cancellationToken) in /src/src/NoWow.EmailService/FirebaseClient.cs:line 67

To confirm my credentials is valid I did:

var credential = CredentialFactory.FromFile<ServiceAccountCredential>(options.Value.FIREBASE_ADMIN_FILE).ToGoogleCredential().CreateScoped(
    "https://www.googleapis.com/auth/firebase.messaging",
    "https://www.googleapis.com/auth/cloud-platform");
var accessTokenForRequestAsync = await credential.UnderlyingCredential.GetAccessTokenForRequestAsync();
Console.WriteLine("Access token: {0}", accessTokenForRequestAsync);

The above test returned an access token confirming my credentials are valid

Ngôn ngữ chính
C#
Star
407
Fork
147
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firebase/firebase-admin-dotnet

Tất cả issue của firebase/firebase-admin-dotnet

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.