title: Flask-Security API Token
body: <p>I have a Flask-Admin app running with Flask-Security and use a token based authentication for API calls. Everything was working correctly. The following method is what returned the token.</p>
  
  <pre><code>def get_token(self): 
          url = 'http://nginx/login'
          headers = {'Content-Type':'application/json'}
          data = {'email':os.environ['SCRAPER_USERNAME'], 
                 'password':os.environ['SCRAPER_PASSWORD']}
          response = requests.post(url, headers=headers, data=json.dumps(data))
          jsonresponse = json.loads(response.text)
          self.token = jsonresponse['response']['user']['authentication_token']
  </code></pre>
  
  <p>I have now added templates to the login and logout pages of Flask-Admin and changed the urls to /admin/login. So I changed the one line from <code>url = 'http://nginx/login'</code> to <code>url = 'http://nginx/admin/login'</code> I thought this was all that was necessary but unfortunately I am now experiencing issues. This method now returns a 400 error when trying to load nginx/admin/login.</p>
  
  <p>Nginx is the server running in a docker container. So it appears creating custom templates has caused the issue. Would anyone know why and how to resolve it?</p>