admin管理员组文章数量:1391987
Following is my request
Request: POST :batchAdd Headers[access_token_auth=true authorization=eyJ0e_access_token Content-Type=application/json Body: {"registration_tokens":["xxccvc_dummy"],"to":"/topics/my_topic"}
and I am getting reponse
POST :batchAdd, Status[302 Moved Temporarily], Headers[Location=;passive=1209600 Content-Type=text/html;
This is how I am getting access token
Jwt.issuer(serviceEmail)
.scope(";)
.subject(serviceEmail)
.claim("kid", myConfig.fcmJwtKid())
.audience("/")
.issuedAt(Instant.now())
.expiresAt(Instant.now().plus(1, ChronoUnit.HOURS))
.sign("jwt-private-key.pem");
I have gone through almost all the documentation but could not find any reason that why I could receive this?
Following is my request
Request: POST https://iid.googleapis/iid/v1:batchAdd Headers[access_token_auth=true authorization=eyJ0e_access_token Content-Type=application/json Body: {"registration_tokens":["xxccvc_dummy"],"to":"/topics/my_topic"}
and I am getting reponse
POST https://iid.googleapis/iid/v1:batchAdd, Status[302 Moved Temporarily], Headers[Location=https://accounts.google/ServiceLogin?service=ac2dm&passive=1209600 Content-Type=text/html;
This is how I am getting access token
Jwt.issuer(serviceEmail)
.scope("https://www.googleapis/auth/cloud-platform")
.subject(serviceEmail)
.claim("kid", myConfig.fcmJwtKid())
.audience("https://fcm.googleapis/")
.issuedAt(Instant.now())
.expiresAt(Instant.now().plus(1, ChronoUnit.HOURS))
.sign("jwt-private-key.pem");
I have gone through almost all the documentation but could not find any reason that why I could receive this?
Share Improve this question asked Mar 14 at 15:19 FreakFreak 6,8935 gold badges40 silver badges56 bronze badges 1- 1 Have you tried following the (temporary) redirect? I'm unfamiliar with this service but it also appears to be deprecated (developers.google/instance-id/reference/server) – DazWilkin Commented Mar 14 at 18:02
1 Answer
Reset to default 0The scope https://www.googleapis/auth/cloud-platform is a very broad scope that grants access to many Google Cloud services, but it might not be specific enough for Firebase Cloud Messaging (FCM).
For FCM operations, a different scope is usually needed, specifically https://www.googleapis/auth/firebase.messaging.
Permissions to assign in IAM & Admin like Firebase Admin (
roles/firebase.admin
) and Cloud Messaging Admin (roles/firebase.messaging.admin
).
Jwt.issuer(serviceEmail)
.scope("https://www.googleapis/auth/firebase.messaging") // Correct scope for FCM
.subject(serviceEmail) .claim("kid", myConfig.fcmJwtKid())
.audience("https://fcm.googleapis/") // Ensure the audience is correct
.issuedAt(Instant.now())
.expiresAt(Instant.now().plus(1, ChronoUnit.HOURS))
.sign("jwt-private-key.pem");
Correct Authorization Header in your request by trying to pass the authorization header in the correct format of Authorization: Bearer <access_token>:
POST https://iid.googleapis/iid/v1:batchAdd
Authorization: Bearer <your_access_token>
Content-Type: application/json
{
"registration_tokens": ["xxccvc_dummy"],
"to": "/topics/my_topic"
}
本文标签: javaGoogle cloud Identity api returns 302 when call batchAddStack Overflow
版权声明:本文标题:java - Google cloud Identity api returns 302 when call batchAdd - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744647116a2617462.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论