When i try submit scores from Android Unity game i receive next error:
You are trying to load data from a www stream which had the following error when downloading.
ava.io.FileNotFoundException: https://graph.facebook.com/me/scores
FB.Login("publish_actions", OnLoginComplete);
var query = new Dictionary<string, string>();
query["score"] = "110";
FB.API("/me/scores", Facebook.HttpMethod.POST, delegate(FBResult r) { Debug.Log("!!!! Score submit result: " + r.Text); }, query);
Facebook sdk version 5.1.0
Unity version 4.5.2f1
For posterity, the most common cause of this error is not having your app configured as a "Game" in the app settings on Facebook. OP and I talked elsewhere, earlier, and ruled that out in this case, but for anyone else finding this post via search, make sure you check that.
To clarify, the code starting with "var query" - is it possible that it is running before OnLoginComplete is called? If you've ruled that out, could you verify whether the problem might be with the grant of permissions? An easy way to do that would be to log the value of the access token right when you make the call to FB.API, then copy-paste that into the access token debugging tool at https://developers.facebook.com/tools/debug and verify that it actually has publish_actions. You could also just take that token and use it in curl in verbose mode (curl -kv "https://graph.facebook.com/me/scores?score=110&access_token=TOKEN"), and see if the headers or response body gives any additional clues.
Related
For example if I executed code like this:
Firebase.auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener { task -> signInCompletedTask(task) }
I would like to see what http request (and with what headers) is actually sent to Firebase backend.
What I tried:
To find anything useful in logs, but I didn't see any information about this.
To run application with debugger, but inside FirebaseAuth.class everything went so complicated that I still couldn't figure out where is the actual http request made.
I tried to look for a source code for com.google.firebase.auth.FirebaseAuth.java, I found this https://github.com/firebase/firebase-admin-java/blob/master/src/main/java/com/google/firebase/auth/FirebaseAuth.java but this class seems wrong, it doesn't even have signInWithEmailAndPassword(..) method
In firebase doc I find this link https://firebase.google.com/docs/reference/rest/auth#section-sign-in-email-password, but I'm not sure is this the same thing or not.
So bottom line, how can I debug what data is moving between my android application and Firebase backend?
firebaser here
The source code you looked at is for the Admin SDK for Java backends, which doesn't have a way to sign in, but has lots of other useful calls for administrative/backend functionality.
For the Firebase Authentication Android SDK the code is in this repo firebase-android-sdk, but you'll find that the Authentication SDK is not in there (yet). If I recall correctly it was too entangled with Play to release it.
The Authentication SDK makes calls to the REST API though, and those endpoints are all documented here, like the API to sign in with email+password.
I need to connect my Android application with Facebook Analytics, using custom events.
I followed official documentation on https://developers.facebook.com/docs/analytics/
Added facebook SDK into the project:
implementation 'com.facebook.android:facebook-android-sdk:5.15.3'
Generated all the necessary hashes, put everything necessary in the Manifest, all good.
App was built and launched, however, events were never showing up in the Analytics Console.
After hours and hours of debugging, I've found the problem.
Inside Facebook SDK library code, when postRequest to server is created, it has (among others) parameter called "extInfo". This parameter should contain json array with strings, in certain order.
Now, that's how Facebook SDK postRequest looks, when sent from the application:
As you can see, extinfo json array is all contaminated with backslashes. When I replicated this request manually in Postman, server returned error:
"message": "(#100) Field extinfo must be a valid json object with string keys"
So, in Postman, I modified extinfo parameter - cleaned it out of backslashes:
Result from server in this case is: "success": true. Events started appearing inside Analytics Dashboard.
Wonderful. But.
How to send events with the help of Facebook SDK, considering this bug? Is there sdk version where this bug doesn't appear? Is there a way to tune sdk so that it doesn't send extinfo at least?
Any other possible solution, except for sending requests without help of Facebook SDK (that's a whole load to write, besides, if they change request structure, code has to be re-written)?
I haven't found metions of this bug anywhere in the Internet. If there is, please share a link. Thank you.
Edit: tried with implementation 'com.facebook.android:facebook-core:7.1.0' too. No luck.
I've found the solution. In my case, problem was inside the project and had nothing to do with Facebook SDK.
Previous developer created validation for hosts that application can use:
HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory)
val verify = fun(ip: String, _: SSLSession): Boolean {
println(ip)
return ip.contains("crashlytics", true) ||
ip.contains("firebase", true) ||
ip.contains("maps.googleapis.com", true) ||
ip.contains("facebook.com", true)
}
HttpsURLConnection.setDefaultHostnameVerifier(verify)
Once I added facebook.com in the list, error was gone. However, I still don't understand why in the log "extinfo" parameter was generated with backslashes.
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
Using the Mobile Backend Starter (MBS) Android classes (those distributed as a sample project when creating a new project in Google Dev Console and demoed at Google I/O 2013) I'm able to insert new entities to the cloud datastore via calls to CloudBackendMessaging.insertAll or .updateAll. The latter will create entities if none exist so seems functionally identical to insert for new records.
The insertion/creation works fine. However when I attempt to update existing entries in the datastore, I received permissions errors e.g. (from the backend log)
Method: mobilebackend.endpointV1.updateAll
Error Code: 401
Reason: required
Message: Insuffient permission for updating a CloudEntity: XXXXXX by: USER: YYYYYYY
which results in a matching access error in the logcat client side.
In all cases I am using Secured access authenticating with a valid Google account (my own).
The entities being inserted are thus showing as "owned" by my user ID with "updated by" and "created by" showing my Google account's email address.
However when the update of the existing record is made, using exactly the same CloudBackendMessenger object and thus same credentials etc. the backend is telling me I can't update due to permissions issues. But surely if I just made the entity with the same credentials this can't be correct? Looking at the documentation it appears that I should be able to edit entities owned by the same user ID in all cases (regardless of the KindName and whether it is prepended [public], [private] or nothing).
Can anyone who has received permissions errors on UPDATES via Mobile Backend Starter for Datascore please shed any light? I have been banging my head over this for most of today.
I've faced the similar error "Insuffient permission for updating a CloudEntity" when using cloudBackendAsync.update(cloudEntity). I resolved it by making sure the cloudEntity has it's createdAt field set. createdAt is autogenerated and I think I am not supposed to touch it. But it worked for me. In my case I am first obtaining list of cloud entities. This is when I get createdAt field of cloud entities. Then when I am updating I setting the createdAt field from previously obtained entities.
Edit: Had to do similar thing for owner field also.
Similar to one of the comments above, I successfully got around this by getting the original CloudEntity before doing the insert/update/delete function.
CloudQuery cq = new CloudQuery("datastoretype");
cq.setLimit(1);
cq.setFilter(Filter.eq("_id",id));
cloudEntity.setId(id);
mProcessingFragment.getCloudBackend().get(cloudEntity, handler);
Thereafter it was trivial to do the following:
mProcessingFragment.getCloudBackend().update(cloudEntity, handler);
The docs definitely ought to be more clear on this, whether it is a strict requirement or bug.
The answers posted so far work around the problem if you don't mind all users being able to access the entity you are trying to update. However, a better solution that retains the access permissions is detailed by google here - https://cloud.google.com/cloud/samples/mbs/authentication
If you want to pass the user’s Google Account info to the backend on
each call, use the CloudBackend#setCredential() method (also available
on the subclasses, CloudBackendAsync and CloudBackendMessaging) to set
a GoogleAccountCredential object before calling any Mobile Backend
methods.
GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(this, "<Web Client ID>");
credential.setSelectedAccountName("<Google Account Name>");
cloudBackend.setCredential(credential);
Setting credientials enables the client to operate when the backend is
in “Secured by Client ID” mode and also sets createdBy/updatedBy/owner
properties of CloudEntity automatically.
In my android application, I would like to retrieve the birthday field from google.com/contacts, as this field isn't synchronised in the android contacts application.
How can I have a read access to google contacts ?
I saw the Google contacts APIs, did I have to use it ? which one ? the Portable version ?
Or is there a simple way to read these contacts, as Android does when there is a synchronisation ?
Thanks in advance
There used to be a hack before the AccountManager was reased, I started a thread about a year ago on the android developer group, but it has been removed. There was an undocumented method that you had to access through reflection. I can't seem to find it anywhere now, like google has deleted the thread or something. I found something similar below, but it's not the one I had working.
http://donpark.org/blog/2009/01/24/android-client-side-oauth
At worst case, most devices that are out now, should eventual get 2.1. So you could just make them login then validate and get the auth key from google, and if they are on 2.1 use the AccountManager and don't bother them with the credentials. something like below
WebRequest req = HttpWebRequest.Create(
#"https://www.google.com/accounts/ClientLogin? accountType=GOOGLE&Email=them#gmail.com&Passwd=pass&service=gbase&source=sadboy");
WebResponse resp = req.GetResponse();
string all;
using (StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()))
all = sr.ReadToEnd().Trim();
int auth = all.IndexOf("auth=");
string auth = all.Substring(auth, all.Length - auth);
https://developer.android.com/about/dashboards/index.html
It should be possible since android 2.0 using AccountManager.
There are no tutorials nor samples, I don't have access to any >=2.0 device to try it out.
See http://code.google.com/p/android/issues/detail?id=1073#c28
As I understand you should be able to getAuthToken fo Google account and pass it in Authorization header as here Authorization: GoogleLogin auth=yourAuthToken