Where is GCM documentation for 'InvalidTokenVersion' error? - error-handling

I am using the Google Cloud Messaging services described at https://developers.google.com/instance-id/reference/server but I am getting a HTTP response status of 400 and this response text:
{"error":"InvalidTokenVersion"}
At the time I write this, that exact error code has zero results on Google! Has anyone else encountered it? I could understand "InvalidToken" but it is the "Version" bit which is confusing me.
I'd like to see a nice list of all the possible error codes for the https://iid.googleapis.com/iid/info/ and https://iid.googleapis.com/iid/v1/*/rel/topics/* services, if you know where that is?!
All the GCM pages say at present is...
HTTP status 400 (Bad request) - request parameters are missing or invalid. Check error messages for detailed information.
Background information:
I am using a registration token from an Android device which still shows a log of successful notifications in the GCM Diagnostics (part of Google Play Developer Console). So surely the token cannot be wrong?
If I try a token value of "bum" I get error "InvalidToken" instead.
However, trying to send a new notification with https://gcm-http.googleapis.com/gcm/send results in the "InvalidRegistration" error, so I guess something has gone screwy.
I'd like to claim that I've changed nothing recently, but something to do with SSL on the server might have expired I suppose.

The token you are providing is regId not instanceId.token. Follow the documentation:
https://developers.google.com/cloud-messaging/android/client.
see examples here.
https://github.com/googlesamples/google-services/tree/master/android/gcm/app/src/main/java/gcm/play/android/samples/com/gcmquickstart

Related

Google Home "Couldn't update the setting. Check your connection.'

So this type of error is being reported on a lot of community boards over the course of the last year with no acceptable answer we could find. We have just started our journey integrating with Google Home and created a Home Automation Action and we are getting a similar error …
{
insertId: "10wvnj2fyb1thy"
logName: "projects/bitdog-home-f69bd/logs/actions.googleapis.com%2Factions"
Show matching entries
Hide matching entries
Add field to summary line
receiveTimestamp: "2018-12-06T13:28:13.939975519Z"
resource: {
labels: {
action_id: "SMART_HOME_SYNC"
project_id: "bitdog-home-f69bd"
version_id: ""
}
type: "assistant_action"
}
severity: "ERROR"
textPayload: "SYNC: Request ID 742344561631232315 failed with code: OPEN_AUTH_FAILURE"
timestamp: "2018-12-06T13:28:13.931998358Z"
}
This shows on Google Home app as "Couldn't update the setting, check your connection"
The OAuth service logs show a successful account linking and a successful refresh_token request. Google does not attempt a SYNC call to the Action handler from what we can tell.
We have other systems using the OAuth server and they are working well and we are little lost on how to proceed to debug this issue. We created a support ticket today but I don't feel confident that we will get meaningful help.
We have also tried using the Google Home app on Android and iOS. We have tried changing the default browser from Chrome to Firefox. Nothing has changed the outcome. We also made sure that our access_token was in JWT format to see if google was sensitive to token size or format and nothing worked. We even made sure that the Google Home app user matched the user logged into the browser.
Help!
I did get it working. It was already working with an Amazon Echo Skill but it seems that Google's implementation (OpenAuth) is a bit more strict. I changed my access_token from a proprietary encrypted token format to a legit signed JWT token. I also removed expires_in from the response and it started working, not sure if it was the access_token JWT token format or removal of expires_in. I'm happy I can move on. If I get a chance, I will test to see which change made it work and comment here again.
Thank you.
To anyone with this problem–
I had to take multiple steps to resolve this issue, which are not clearly outlined in any documentation.
As per Google support:
Please adjust your account linking implementation from implicit to auth code flow then perform test again.
On the documentation for OAuth account linking, it says there are two methods of authentication: implicit and auth code. Apparently, only the auth code flow works for smart home.
I am using the Actions on Google Node.js library. While poking through the documentation, I found that:
[The SYNC request fulfillment] should return a valid response or a Promise that resolves to valid response.
The problem is that I was doing a database operation (which took time), so I couldn't simply return a value when it was ready; I had to return a Promise insead, then fulfill that promise later.
Hopefully this is helpful to anyone stuck on this reoccurring issue! Basically, check your auth flow and make SYNC is returning a valid JS object on time.
I was facing the same issue from last 2 weeks and was wonder when saw it is a 3 steps problem.
Check your SYNC intent is properly parsed
Incorrect Response Structure (Verify here-Smart Home SYNC Data Validator)
Device Response time-out should be less than 5 sec.
You can check Link
My problem started when I connected by Sonoff Bridge.
So I got it working by removing my 'Sonoff Bridge' and connecting it to Google Home. (All mu light are now working). Added the Bridge again to Sonoff and using IFTTT to connect to my Bridge

Soundcloud API "Request was not processed"

I'm seeing a new error via the Soundcloud API. It is intermittent, so it may be backend+bug related or it could be a sign of further reduced access to the Soundcloud API.
A User request now returns the following:
https://api.soundcloud.com/users/cadenzamusic?client_id=CLIENT_ID
(replace CLIENT ID with your own)
An HTTP/1.0 200 OK response is returned, but I'm getting the following string, rather than the User JSON object as expected:
Request was not processed by the server due to an error and is safe to retry
Is anyone else experiencing this?
As I stated earlier this was an error on SoundClouds part. Their servers were experiencing issues and it seems that they have resolved since 17:26 CET/ 08:26 PST
If you want more information on the status check out their post here.
When experiencing similar issues in the future it might prove useful to check the SoundCloud status page to see if they are aware of any issues.

how to validate Apple APN device token - WCF .NET

I am building a WCF REST web service that is called by the mobile app to insert the Apple device Token into the database. I would like to validate a device token before inserting into the database. Is there anyway to validate a device token to know if it is valid??
I have searched around the forum and could not find any sample code (in .NET) to do this, there were recommendations that I should use the Apple FeedBack service but how do I do that in .NET??
Could anyone please provide me a piece of sample code to validate an Apple Device Token in .NET.
Many thanks,
You can't validate the device token. The only thing you can validate before inserting the token to your DB is that its length is 32 bytes (in binary representation) or 64 Hexadecimal characters (in a String representation).
Beyond that, you should check the responses from Apple to see if you get an InvalidToken error response. If you do, you know the device token sent with the message that causes the error is invalid.
The Feedback Service does not return invalid tokens. It returns valid tokens of devices that uninstalled your app.
I can't give you any C# code, but PushSharp should support calling the Feedback Service and reading error responses from Apple.
This is the little irrelevant answer, but recently i came across this question, as my problem was that i have long list of Notification Token and in that some of them are invalide.
So i need to filter them, but there is not easy way for that but there is 1 app that i use to send/test notification certificate,
Knuff : https://github.com/KnuffApp/Knuff/releases
In that if you give it wrong notification token than it will display error like this,
So that way anyone can validate the push notification token.
Hope it will help user like me.

Sharepoint 365 ACS OAuth in Objective-C: realm error - Help Needed

Okay, so we are building an iPhone app to hit a Sharepoint 2013 site that is hosted on Office 365. If I were building this in C#, which I've already done, I would have the luxury of just using TokenHelper.cs to get me most of the way there. Unfortunately, as far as I know, there is no TokenHelper for Objective-C yet.
So here's the deal, we can already successfully get the OAuth authentication/authorization page to come up and we successfully get an Authorization Code back.
After this point we were stumped for a bit because we knew that we were missing the realm id in the POST for obtaining our Access and Refresh tokens. I finally figured out how TokenHelper does this and we've duplicated that. (This was an additional call to /_vti_bin/client.svc where you expect to get a 401 so that you can pull the realm id out of the header)
We now have a realm id that, from what I've read in documentation and TokenHelper and seen in Fiddler, needs to then get used in the following 2 ways: within the URL construction for the POST as well as for the resource value in the header for that POST.
So the POST url looks like this:
accounts.accesscontrol.windows.net/{realm id}/tokens/oauth/2
Our resource value looks like this:
resource=00000003-0000-0ff1-ce00-000000000000%2f{realm url}%40{realm id}
This at least connects fine and accepts our POST. Unfortunately, we are getting the following message back:
ACS50012: Authentication failed. ACS90011: The realm '' is not a configured realm of the current service namespace.
This message makes me think that there may be a configuration issue, but I really can't be sure.
Has anyone else tried performing OAuth against a 365 site yet within Objective-C and had success?
I can post code as well, but I was trying to shy away from that initially.
I recently came across the same problem and have a feeling it may be the same issue you are seeing.
The correct POST request for OAuth is as follows:
POST https://accounts.accesscontrol.windows.net/<REALM_GUID>/tokens/OAuth/2
x-www-form-urlencoded params:
grant_type:authorization_code
client_id:<CLIENT_ID>#<REALM_GUID>
client_secret:<CLIENT_SECRET>
code:<AUTH_CODE>
redirect_uri:<REDIRECT_URI>
resource:00000003-0000-0ff1-ce00-000000000000/<SHAREPOINT_AUTHORITY>#<REALM_GUID>
The major gotcha for me was that the value of the "client_id" required the realm id appended to the client id. Not including the realm id will throw an "ACS90011: The realm '' is not a configured realm of the current service namespace."
HTH

C2DM - problems when Using the new AuthToken after I get Update-Client-Auth

Im developing push notification server that works with google's C2DM service.
When I get "Update-Client-Auth" in the response header , I replace the previous token , for use on the next push notification.
When I send notification right after I got new token , it fails -
with the response - "InvalidRegistration"
My questions are ?
How to avoid this ? Should I wait before I use the new token ?
When do I need to start using the new token ? is the expiration date included on header should be used ?
I havent found this phenomenon mentioned anywhere.
thanks for any advice.
I don't think the problem is with your Auth. token.
"InvalidRegistration" means that the Registration token of the device to which you're sending the C2DM Message is invalid. You should make sure that the device sends you an updated Registration Id/token if it changes (apparently it can).
Clear your server cache/DB and start again by getting the device to re-register with Google and then send the registration token to your server and see what happens.
Of course, I'm guessing you don't have lots of registrations in your DB, if you're still in development...
Regards,
Mark