java - How to authenticate android user POST request with Django REST API? -


as of now, have django rest api , hunky dory web app, wherein have implemented user auth in backend. "login_required" condition serves web app, cookie based.

i have android app needs access same api. able sign in user. need know how authenticate every user when make get/post request views?

my research shows couple of solutions: 1) cookie-backed sessions 2) send username , password every get/post request(might not secure)

any ideas?

it sounds you're using django rest framework in case tokenauthentication might suitable. docs:

this authentication scheme uses simple token-based http authentication scheme. token authentication appropriate client-server setups, such native desktop , mobile clients

you don't need pre-generate tokens clients can ask 1 using built-in view obtain_auth_token configure in urls.py.

once client has obtained token session can provide on subsequent api calls using authorization: http header.

check out docs more info: http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -