V
V
Vasily Vorobyov2016-03-07 12:16:41
CSRF
Vasily Vorobyov, 2016-03-07 12:16:41

How to authorize android app in django-rest-framework?

There is a url for authorization through the rest, but even there csrfmiddlewaretoken is requested. Accordingly, a simple transfer of login and password does not work.

<form method="post" role="form" action="/api-auth/login/">
              <input type="hidden" value="KLJVW0Zf1CXOaBrG4mp3NVrf7AJHw9iO" name="csrfmiddlewaretoken">
              <input type="hidden" value="" name="next">

              <div class="clearfix control-group " id="div_id_username">
                <div class="form-group">
                  <label for="id_username">Username:</label>
                  <input type="text" value="qwe" required="" id="id_username" class="form-control textinput textInput" autocorrect="off" autocapitalize="off" maxlength="100" name="username">
                  
                </div>
              </div>

              <div class="clearfix control-group " id="div_id_password">
                <div class="form-group">
                  <label for="id_password">Password:</label>
                  <input type="password" required="" id="id_password" class="form-control textinput textInput" autocorrect="off" autocapitalize="off" maxlength="100" name="password">
                  
                </div>
              </div>   
                  <div style="border: none" class="well well-small text-error">Please enter a correct Email and password. Note that both fields may be case-sensitive.</div>
                
              

              <div class="form-actions-no-box">
                <input type="submit" id="submit-id-submit" class="btn btn-primary form-control" value="Log in" name="submit">
              </div>
            </form>

Do I need to disable csrf protection or is there a way to authorize using a token?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Voronkov, 2016-03-07
@DmitryVoronkov

django-rest-frameworktokenauthentication

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question