Hello

I'm am stuck in a problem dealing with an CORS request from a phonegap app 
to an django application.

What I have so far is the following:
- a regular django web project
- a phonegap app build on angularJS for some settings.


   - The idea is, that users can use the app to store relevant server 
   informations like host, port, etc.
   - The app requests a token from the django project that identifies the 
   user and uses it for further page loads.
   - Via a link or other redirect the app calls the django site and log in 
   the user 

At the moment i can call the django site by using the app but the user has 
to log in manally.
This has to be automated.

Therefore i added the "REST Framework" and "JWT auth" to the django project.

a curl call to the project results in a correct JWT token.
curl -X POST -d "username=djangoadmin&password=secret" http:
//192.168.1.183:8080/api-token-auth/

Well the question is now how to implement this call in the app due the CORS 
situation.

I tried some examples like

   - http://www.html5rocks.com/en/tutorials/cors/
   - 
   http://jamesbrewer.io/2014/10/31/json-web-token-authentication-part-two/

but all failed :)

another try was:

var params = "username=" + user + "&password=" + passwd;
            
var xhr = Utils.createCORSRequest('GET', 
'192.168.1.183:8080/api-token-auth/');
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.setRequestHeader("Content-length", params.length);
xhr.onload = function () {
   console.log(this.responseText);
};
xhr.send(params);

So far i would say my knowledge for the CORS situation via JQuery is a bit 
too low.

Maybe someone has an idea how to request the token inside the app and later 
on use it to call the django site and make an auto login.

Any help welcome :)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/34f27d1f-a282-477e-87d8-dffbfa62de2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to