Way to detect invalid device token in FCM HTTP v1 API - firebase-cloud-messaging

we are using FCM HTTP v1 API to send push notification.
When, our users register their device tokens, our push server just stores it to database without verification because FCM does not provide token verification APIs.
The only time the push server could detect whether the device token is valid or not is when sending push notification via FCM.
According to FCM registration token management, if the device token is invalid the FCM server responds with UNREGISTERED or INVALID_ARGUMENT.
However, the INVALID_ARGUMENT code can be returned when using invalid payload as well. So we can not distinguish errors between invalid device token and invalid payload.
The following is actual response from the FCM server in case of using invalid device token and invalid payload respectively.
{
"error": {
"code": 400,
"message": "The registration token is not a valid FCM registration token",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "INVALID_ARGUMENT"
}
]
}
}
HTTP/1.1 400 Bad Request
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"priority\" at 'message': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "message",
"description": "Invalid JSON payload received. Unknown name \"priority\" at 'message': Cannot find field."
}
]
}
]
}
}

When the token has a proper format but its user is no longer active, you will receive an UNREGISTERED response indicating that you should delete that token from your backend.
However, if you send a token that does not have a valid format (it has been modified in your backend or truncated, for instance) you will receive an INVALID_ARGUMENT. If this is the case you probably want to check your code because you may be modifying the token somewhere (in App or backend). Probably you have to manually detect and delete those tokens.
Once this is solved, you do not have to worry anymore about the INVALID_ARGUMENT response to delete the tokens, except if you make further changes that corrupt them again.

Related

Amazon Advertising API throws HTTP 401 Unauthorized

I am trying to generate ads reports
The create report API gives response as
{
"reportId": "amzn1.sdAPI.v1.p44571.6153E22B.2825ae5c-126d-422c-bf10-53d2d601189a",
"recordType": "campaigns",
"status": "IN_PROGRESS",
"statusDetails": "Report is being generated."
}
but the get report status API gives UNAUTHORIZED error
{
"code": "UNAUTHORIZED",
"details": "HTTP 401 Unauthorized",
"requestId": "6C1XJ33DSF546P3XZSD"
}
My first suggestion would be to ensure you’re using a valid access token.
You should also verify correct scope value and clientID in your header.

Format of the address is invalid in IdeaMart Subscription API

I want to subscribe to users to my Ideamart mobile app. This is the sample request I sent to the ideamart API
{
"applicationId": "APP_01234",
"password": "xxxxx",
"action": "1",
"subscriberId": "tel:94761234567"
}
This is the response I got
{
"statusDetail": "Format of the address is invalid.",
"version": "1.0",
"statusCode": "E1325"
}
How should I fix this issue?
This error occurred because the user was not subscribed the application. User must subscribe it first to use the CAAS api.
try after recharging(reload) your mobile account

Twitter Insights API with Postman

I'm trying to read insights of my Twitter account with Twitter Insights API and when I request to that given end point I get and error called :
{
"errors": [
{
"code": "UNAUTHORIZED_ACCESS",
"message": "This request is not properly authenticated"
}
],
"request": {
"params": {}
}
}
This is the end point I tried :
https://ads-api.twitter.com/2/insights/accounts/:account_id/available_audiences
I used the given credentials like Consumer Key, Secret and Token, Token secret.
Can anyone explain me why I'm getting this error ? And what I should do ?
Here is a screenshot
Header:
You have to check box "Add params to header"
Everything else should be ok. Just check Consumer Key, Consumer Secret,... data

Google + access token insufficient permission

Using OAuth code i am able to generate access token for google+ API .
using this access token in oauthpalyground iam getting JSON response .
When I paste this this URL into a browser am get an error message.
https://www.googleapis.com/plus/v1/activities?query=%22great%22&access_token=xxxxxxxxxxx
Error Message
{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
Can anyone explain to me why?
You can not query directly from browser sending the access_token as a querystring. You must send access_ token in headers this way:
Authorization: Bearer <access_token>
Try it with Fiddler or some similar software.

google plus auth returning error 401

I am using Google plus auth to log in in web application. It is working properly, but for some time its return error 401. Error JSON is following. I view link Error Description but I did not understand what should I do.
{
"error":
{ "errors":
[
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
As the error page indicated - your access token has likely expired. It sounds like you got an access token once, and are continuing to use it.
Access tokens expire after an hour. After that time, you either need to go through the auth flow again, or use the refresh token to get a new one.