我正在尝试从我的服务器向我的 Web 应用程序发送通知,它在我的本地项目上工作,但是当我推送它时,firebase 不起作用
try {
FirebaseOptions options = FirebaseOptions.builder()
.setCredentials(GoogleCredentials.fromStream(
new ClassPathResource("myapp-3c3c3-firebase-adminsdk-emn30-37a5092d63.json").getInputStream()))
.setDatabaseUrl("https://myapp-3c3c3.firebaseio.com")
.build();
FirebaseApp.initializeApp(options);
setInitialized();
} catch (IOException ignored) {
}
异常信息:
Unknown error while making a remote service call: Error getting access token for service account: 400 Bad Request
POST https://oauth2.googleapis.com/token
{"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."}
json 配置文件位于 spring 项目的模块资源上
Message message = Message.builder()
.setNotification(Notification.builder().setTitle(title).setBody(contents).build())
.setToken(token)
.build();
return FirebaseMessaging.getInstance().send(message);
答案 0 :(得分:0)
就我而言,问题在于服务器时间比实际时间晚了 10 分钟