Код: Выделить всё
Caused by: java.io.IOException: Error getting access token for service account:
at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:395)
at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:179)
at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:165)
at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:96)
at com.google.firebase.internal.FirebaseRequestInitializer.initialize(FirebaseRequestInitializer.java:55)
at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:93)
at com.google.api.client.http.HttpRequestFactory.buildPostRequest(HttpRequestFactory.java:133)
at com.google.firebase.messaging.FirebaseMessagingClientImpl.sendSingleRequest(FirebaseMessagingClientImpl.java:147)
at com.google.firebase.messaging.FirebaseMessagingClientImpl.send(FirebaseMessagingClientImpl.java:125)
... 13 more
Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request
{"error":"invalid_grant","error_description":"Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe. Check your iat and exp values in the JWT claim."}
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1072)
at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:393)
... 21 more
У меня есть выполнили указанные ниже проверки/исправления:
- Проверил, что файл JSON с учетными данными сервисной учетной записи доступен на сервере разработки.
- Проверил, что переменные среды установлены. правильно.
- Подтверждено, что сервер разработки имеет надлежащий сетевой доступ к сервисам Firebase.
- Синхронизировано время сервера (поскольку в ошибке упоминаются проблемы с истечением срока действия токена), обратите внимание, что он размещен в Сингапуре.
- Убедилось, что у сервисного аккаунта есть достаточные разрешения для отправки уведомлений.
- Сервер разработки Среда: монолитное развертывание без использования Docker или контейнерных сред, размещенное в Сингапуре.
- Firebase Версия SDK: firebase-admin 6.8.1
- Версия Java: 8
- < strong>Версия Play Framework: 1.0-SNAPSHOT
Код: Выделить всё
@Override
public void sendNotificationByTopic(String topic, String title, String body) {
ExecutorManager.getExecutorService().execute(()-> {
try {
// create the message for the topic
Message message = Message.builder()
.putData("title", title)
.putData("body", body)
.setTopic(topic)
.build();
// send the push notification
try {
FirebaseMessaging.getInstance().send(message);
} catch (FirebaseException e) {
LOGGER.info("Encountered an exception while sending push notification for the topic");
}
} catch (Exception e) {
throw new FirebaseMessageException("Encountered a generic exception in sendNotificationByTopic");
}
});
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... -access-to