I am trying to get the access token for Baidu Push Notification. I've done everything according to their SDK documentation and I am able to send push notifications from their console. I went through their documentation and I am using this line of code to start the service.
PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_API_KEY, Utils.getMetaValue(SplashActivity.this, "api_key"));
there is another method that uses
PushManager.startWork(getApplicationContext(), PushConstants.LOGIN_TYPE_ACCESS_TOKEN, Utils.getMetaValue(SplashActivity.this, "api_key"));
but I can't seem to get it to work or get the access token, probably due to a mistake in the code I am using. Could anyone guide me? I am able to get things like userId, channelId and requestId when I use the first method though, would one of these be the access token instead?
When I use the second method I get a "30603 Illegal construction request, server-side validation failed" error.
All of the guides are in Mandarin and Google Translate could only go so far. Help would be much appreciated.
You can find your resultCode like this.
your resultCode
code error list
Related
I try about week to send notification between devices using Firebase Functions now i found delay or the notification don't received to another device so after many trys i found solution is iam generate wrong token so i seek now the right way to generate tokens
FirebaseInstanceId.getInstance().getToken()
its return wrong token
extends FirebaseMessagingService
cant know how it works and after many tries it still return null
I'm trying to build chat application on Android and I've stuck on a very first step. I can't create ChatClient. According to documentation I should call some method like this:
ChatClient.create(context.getApplicationContext(), token, props, myCallback);
Unfortunately I'm receiving error: "Invalid access token grants", you can check this link for error details.
I've verified what's inside my jwt access token and it seems that everything is OK with grants. I've used https://jwt.io/ debugger to test it and could see the following payload(I've dashed my credentials to show only structure):
{ "iss": "SK####################",
"exp": 1516198358,
"jti": "SK#####################",
"sub": "######################",
"grants": {
"identity": "test.user#mail.com",
"chat": {
"service_sid": "###################",
"endpoint_id": "###################"
}
}
}
I've checked all the values and they seem to be OK, I've also tried to copy this token and pass it to my web(JS) project and was able to sign in without any issues which proves that token itself should be OK.
Any help appreciated, thanks
So the solution was to use correct region setting, because tokens in one region are incompatible with services from another.
Error messages on the service side are being refined to better reflect this case.
please do not use "endpoint_id" in the grants, it has been deprecated and may be throwing off some service validation logic.
If you continue getting this error please contact support.twilio.com and provide adb logs and the token itself (do not paste it here publicly). Also see https://github.com/twilio/twilio-chat-demo-android/blob/master/REPORT_BUGS.md
I’m implementing Firebase Cloud Messaging (FCM) and am experiencing a problem that I’m unable to solve. I have implemented FirebaseMessagingService and FirebaseInstanceIdService according to the guide(s). When I go to Firebase Console for my app, and use the Notification function, I can successfully send a message to ALL my app instances (using the package name).
Now, in the code I have fetched the Firebase Instance Id (token) by use of the following code:
String token = FirebaseInstanceId.getInstance().getToken();
SendFirebaseTokenToServer(token);
(note that currently I’m using HTTP protocol, as my server does not yet have a cert). Anyway using the token I get from the call above, I go back to the Firebase Console and try to send a message to one (1) installed instance of my app. I grab the token from our server DB where it is stored as "varchar(max)". When I do that I get the following error message:
Invalid registration token. Check the token format.
I have googled that and found only one hit (having to do with Firebase and iOS):
http://stackoverflow.com/questions/41343520/ios-invalid-registration-token-check-the-token-format
That issue indicates that a cert was required (I think I’m reading it correctly). I’m not sure what I’m doing wrong. I need to get this to work using the Firebase Console first, then my server guy can start on his end knowing that it should work.
Turns out i was programatically encoding all POST or PUT parameters prior to sending to our server. the FCM token had a semicolon in it, which got encoded to a "%3A", seemingly causing the problem.
do NOT encode the FCM token.
I try to use Google oauth to authenticate users on my android app.
Then I would like to send it to my app server so it can connect at any time with Google calendar.
I tried to use
GoogleAuthUtil.getToken(getApplicationContext(), mAccountName, mScope);
Following this article:
https://developers.google.com/accounts/docs/CrossClientAuth
When I use it with scope
mScope = "oauth2:https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile";
I get a token, which is valid for an hour
But when I try to get an authorization code (so I can get a refresh token that is valid for longer time, using
mScope2 ="oauth2:server:client_id:{CLIENT_ID}.apps.googleusercontent.com"+ ":api_scope:https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile";
I receive either "invalid_scope" or "Unknown" exceptions.
What am I doing wrong?
EDIT:
OK, After creating a new app on google API console and adding plus.login to the scope I get a code, but for some reason my server can't resolve this token. When tying to resolve server gets an error about the redirection URL.
BTW, When I do the web flow with same parameters it works.
OK, found the solution, I expected Google to have a lot better documentation about working with Google Oauth and Android. A few things you have to know to work with Android and offline token
When you create google Client ID Don't create a service application before you create a web application
Must include https://www.googleapis.com/auth/plus.login in your scope
The weirdest, to resolve the one time authorization code on my server, I had to use the redirection URL from the Android client ID details (which doesn't even look like a url) and not from the Web client details on Google API console.
That scope string is only documented to work when passed to GoogleAuthUtil(), see http://developer.android.com/reference/com/google/android/gms/auth/GoogleAuthUtil.html, on Android. But it would be cool if it worked on iOS too; our infrastructure there is a little behind where we’re at on Android.
I have had the same issue then i realised that my app is not published and is in debug mode, so i had to add test users to the Google project -> Consent Screen, then i was able to fetch the token for the added test user.
You just need to follow the correct steps/format for specifying the scopes. Find them here https://developers.google.com/android/guides/http-auth#SpecifyingScopes
I have been playing with Google C2DM, and managed to successfully get the push working. When I was trying to understand the code,
The C2DMReceiver class of Google C2DM, has a constructor in it, which has the following lines
public C2DMReceiver() {
// Email address currently not used by the C2DM Messaging framework
super("dummy#google.com");
}
My question is, what does this email denote? Is it the same if I remove the super statement?
Any help would be appreciated.
Thanks
Nithin
The reason for that is because Google uses that email address only as a reporting mechanism and doesn't really use it for anything else. So for now you can just supply anything and it will still work but it is advised to use the email address you used to register for the push notification services.