I'm building a short python script, logging into a website and grabbing some data on the page, using requests.
The script runs perfectly fine on my Mac, but when launched in Kivy Launcher, I get a certificate error, and the data is not grabbed
The code is as follows :
s = requests.session()
response = s.post('URL', data=form)
responsetext = response.text
On my Mac, responsetext is the data I need. On Android, I get the same message as here : "SSL: CERTIFICATE_VERIFY_FAILED" Error and the variable remains empty. I of course have tried the solutions proposed in the said post, but they are of course NOT working.
I can't use Kivy's UrlRequest because I need to stay logged into the website (and thus using Requests' sessions)
Thanks !
Related
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 making a simple HTTP POST request using Tasker app, it's working fine but somehow it's not sending my arguments. HTTP GET is working fine. What am I doing wrong?
The only thing the server does is JSON stringify all received parameters and return them like: Text: { parameters }
HTTP GET is working:
HTTP POST works, it returns the response "text: {}" but doesn't return any parameter:
Now sometimes it shows "Bad Request Error 400"
I've tested it with another server and this issue persists...
Here's a fiddle to send get and post requests to the same server and both work.
I've exported my task as xml for you to test: You can download it here
Thanks in advance guys!
I have done a little testing with what you have supplied. It appears that your post parameters are making it to the server but %HTTPR is not getting populated. The Tasker documentation says that this variable will be populated if the response is "text-based", but this does not seem to be the case. I may not know what Tasker considers to be "text-based", but I have tried "text/plain" and "text/html" with no luck.
The work-around that I have come up with is to put the response into a file using the "Output File" field of the post task. (Leave "Content Type" blank or this won't work.) You can then read the file into a variable and do what you need to.
This is either a defect in Tasker, incorrect documentation, or just a misunderstanding of what it takes to make it work. This work-around, however, will get you what you need.
Here is a link to a GitHub repository with the updated task export. You may need to change the output file name/location to work with your device.
Update:
Since I posted the above solution, I have run across a Tasker plugin called "RESTask for Tasker". Evidently, Tasker has enough issues with HTML requests that a separate plugin was needed. I have tested this plugin with POST and it does work, so this is another way to go. The plugin is available on the Google Play store.
iam a user of a aspx website ,i recently made a shell script to download a pdf file from the website,the script work very fine 2-3 days..however it stops working after that...the error was 'viewstate validation' error .iam a complete noob in shell programming..
Viewstate value i captured by using curl command:
/wEPDwUJOTcyNDMyNDExZGTFH+8YURsFdHWIPx+4glo2ovFz2w==
Viewstate value i posted using curl command :
/wEPDwUJOTcyNDMyNDExZGTFH+8YURsFdHWIPx+4glo2ovFz2w==
Viewstate value error shown by the aspx webpage:
/wEPDwUJOTcyNDMyNDExZGTFH 8YURsFdHWIPx 4glo2ovFz2w==
As you can see the viewstate value shown by the error page doesnt contain '+' symbol,is this could be the reason for the viewstate validation error?
But i post the data correctly by using curl command..bt i dont know why the error page shows an incorrect viewstate value.any help could be much appreciated
Can the webserver blocked the curl request? Because i used the curl command too often
So i changed the user agent and ip address still showing viewstate error webpage
Instead of auto-generating the validation keys which is the default in ASP.Net specify them explicitly as shown below. These keys are used to validate view state.
Also, in your aspx page try adding these to Page directive at top of your page: ViewStateEncryptionMode="Never" EnableViewStateMac="false".
Generate your own keys explicitly since its a security feature by using IIS Manager as explained at this URL: Generate Keys in IIS
<system.web>
<machineKey
validationKey="21F090935F6E49C2C797F69BBAAD8402ABD2EE0B667A8B44EA7DD4374267A75D7
AD972A119482D15A4127461DB1DC347C1A63AE5F1CCFAACFF1B72A7F0A281B"
decryptionKey="ABAA84D7EC4BB56D75D217CECFFB9628809BDB8BF91CFCD64568A145BE59719F"
validation="SHA1"
decryption="AES"
/>
</system.web>
I made a game with Unity3D which is working on my own android phone fine, but it seems not working on other phones. I don't have access to those phones, but this is what I was told.
More detail: My game is an android app and needs to send data to a server to be stored. The URL is something like this "https://example.com/register". The server is hosted on the google app engine. When a user attempts to send the data he gets an error back which is something like this "java.io.FileNotFoundException https://example.com/register". I checked the logs in my server, there is no record regarding a request from that user. I read somewhere that it's because of htaccess and WWW class and you can't call an URL with htaccess data in it! But there is no htaccess to that page in my server. The page simply receives the data and store them, no authentication needed.
Would be great if anyone has any other idea why some devices get this error and some don't.
string url = "https://my-app-name.appspot.com/register";
WWWForm form = new WWWForm();
form.AddField("playerEmail", playerEmail);
form.AddField("registrationId", registrationId);
form.AddField("playerName", playerName);
form.AddField("playerPass", playerPass);
WWW www = new WWW(url, form);
yield return www;
the server-side then use those provided data and return a simple string.
<?php
$player_name = $_POST['playerName'];
$player_pass = $_POST['playerPass'];
$player_email = $_POST['playerEmail'];
$gcm_registration_id = $_POST['registrationId'];
//store data in the Datastore.
echo "success";
?>
app.yaml
application: my-app-name
version: 1
runtime: php55
api_version: 1
threadsafe: false
handlers:
- url: /register
script: register.php
I also had this problem. The takeaway I had was
Java.io.filenotfound exception is bogus error. It's not anything to do with file io - it's the request failing at the server.
To find the actual error in unity - look at the www requestHeaders - this will give you back the response headers from the request from the server - mine was a 500, but it could be a 400+ type error (especially if you're using authentication).
You can do this by doing a
foreach(var header in request.responseHeaders)
....
If anyone wants I can post my diagnostic code to help out.
Problem with the new App engine connected android application projects for the google eclipse plugin? This is the "Big Daddy" sample shown at goolge i/o 2011. My sample project compiles and the android app appears to work fine and registers with the server. However when I send a message from the server I get the following: Having issue with sample project. Android appears to work fine and registers with the server and the c2dm server, however I cannot send a message.
Also of note on the server is a c2dmconfig datastore object. It has fields for authToken and c2dmUrl. The authToken has a token, however the c2dmUrl is NULL. I suspect this is where my problem lies, but not sure how to fix it.
Thanks Patrick
I found this question by wondering the same thing, if the c2dmUrl being null is a problem. It would seem that this is not an issue though. If you look at the C2DMConfig (the entity that you are referencing), there is a function called "getC2DMUrl". Here it is:
public String getC2DMUrl() {
if (c2dmUrl == null) {
return DATAMESSAGING_SEND_ENDPOINT;
} else {
return c2dmUrl;
}
So null is a supported value for this. If a specific URL isn't specified, it simply returns it to the default.