Passing cookies with PhoneGap's FileTransfer - android

The problem with jquery.cookie and others is that they seem to work well for $.ajax(), but not for PhoneGap's FileTransfer. I have been banging my head on an issue, where I have to pass cookies along with a file. I can access and store the cookies after authentication, but they don't get passed along when I then try to post a file with FileTransfer.
Is there a way to prod FileTransfer to send cookies along?
I am developing mostly for Android.

You can do this by just setting cookies in the document.cookie.

Related

Lumen App authentication

I am building an App API in Lumen, and I am a bit confused about how to lock down what/who can make requests to it.
At present I have no way of authenticating requests from the app, so anyone who knows the link could make requests from a browser and potentially cause havok. I know in the .env file there is an appkey variable which is currently empty, and after some research I can't seem to find a clear answer on what it actually does and if I need it.
So basically:
If request comes from my app, proceed.
If it comes from anything else, stop it.
That is what I am looking for.
I am using Ionic $http to make the requests.
Any help would be great
App Key is used for encryption which you can read at https://laravel.com/
use below command to generate key
php artisan key:generate
For more info on lumen auth check below github, Lumen 5.3 token auth
github link for lumen token auth

Python + Django + Cordova: Reading set-cookie header in Android

I'm using Python2.7 And Django==1.7 on the ServerSide and Cordova==5.3.3 for Mobile ClientSide.
In ClientSide, I've used cookie-base authentication in iOS properly but seemingly Android doesn't support cookies for Cordova based on the documentation.
As you know i can access user's sessionId via cookie in django as below:
def login(self, request, **kwargs):
user = request.user
But in this case maybe i need to access cookie manually because of Cordova limitation.
So my questions are:
Is the any way to access cookie header in Cordova-Android?
If there is not, Whats the best way to get sessionId instead of set-cookie header? custom header or get parameters?
And finally whats the best way to get and validate sessionId manually from session_table of django for current user?
Thanks.

Reading secure cookies in android WebView

I am working on a android web application and based on if a secure cookie exists I want to do something. Unfortunately when I use the following line of code I only get a list of unsecure cookies.
String cookies = cookieManager.getCookie(siteName)
Does anyone know how I can get a list of all secure cookies for a specific domain?
You can retrieve secure cookies by using a url that starts with "https://".
String cookies = cookieManager.getCookie("https://example.com");
Returns all cookies (including secure only ones). Logic for getting cookies can be read at: https://github.com/adobe/chromium/blob/master/net/cookies/cookie_monster.cc#L1780 .
To resolve the issue I added the following before I created the webView
CookieManager.setAcceptFileSchemeCookies(true);
see CookieManager.setAcceptFileSchemeCookies(boolean accept)

Android HTTP Post upload image in webview session

I've been reading for more than three days about this and my head is totally messed up. I saw too much code.. Plaase help!
I have an application with a webview. In this webview I am logged in an account. So this means that when I get to the upload part I must use the webview session. I didn't understand very clear how to work with cookies. Also in the uploader I must set the Content-type and the Content-Disposition.
So my question is: Would you give me an example all this things? Getting the cookies, setting them to the http post request and setting the cookies so I can send the image. Thanks!

Ajax requests on native android apps

I have packaged a Sencha Touch 2 app with PhoneGap for Android. I can't get the ajax requests to work on my native application. When I handle the request through the browser on http://mydomain.com/mysenchaapp/android/assets/www/ it works fine, however, when I run my app through the emulator as a native app my request fails. I think it would be helpful if I could get fiddler to work on handling native apps' request as well, but I haven't been able to figure that out either. Any help is appreciated.
On a native application you can use cross-domain get requests without using JSONP. I got it to work. My problem accessing the servlet was another issue.
You can't use Ajax for Cross-Domain GET requests, you should use JSONP instead. Take a look at the documentation for Ext.data.JsonP.request(), You can however use Ajax to make a post if i'm not mistaken. This comes in handy when uploading something like a base64 string (which is too big for a GET request)

Categories

Resources