我正试图从我的服务器向我的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);
在我的案例中,问题出在服务器时间上,它在实时之后10分钟