Flask-security: "Unauthorized" When I send my token to server

Created on 23 Jul 2017  路  4Comments  路  Source: mattupstate/flask-security

flask + flask security + uwsgi + nginx
On vuejs frontend, they give me this:

<h1>Unauthorized</h1>
<p>The server could not verify that you are authorized to access the URL
requested. You either supplied the wrong credentials (e.g. a bad password),
or your browser doesn't understand how to supply the credentials required.
</p>

I am sure all is good when I run the server locally. The authorization is running well. But not on remote server. Every post/get with token required return me the unauthorized error.

Anyone know the reason? I got know ideas? Should I consider some config of nginx or uwsgi

Most helpful comment

@bsamadi I've been working on a boilerplate that uses Flask-Security token (and session) auth, the code is here: https://github.com/briancappello/flask-react-spa

Files of interest:

The repo is still under active development, but the authentication system works.

All 4 comments

@tim-hub
Are you sure your Flask session is working correctly? Check especially if your SECRET_KEY is set and that cookies are configured and working properly (even if you're storing your session server-side instead of the default in-cookies, cookies are still necessary). Culprits include SESSION_COOKIE_PATH, SESSION_COOKIE_SECURE, and SESSION_COOKIE_DOMAIN. Also make sure you're sending the cookies along with your ajax requests, eg by setting credentials: 'include' if you're using fetch.

Is there a working example of how to send the token to the Flask server?

@bsamadi I've been working on a boilerplate that uses Flask-Security token (and session) auth, the code is here: https://github.com/briancappello/flask-react-spa

Files of interest:

The repo is still under active development, but the authentication system works.

I am trying to find any example to send token, after verifying password, from server to the browser, and then how does that send it back for verification?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LionelR picture LionelR  路  5Comments

joeyespo picture joeyespo  路  3Comments

adamlwgriffiths picture adamlwgriffiths  路  5Comments

lormayna picture lormayna  路  5Comments

asmodehn picture asmodehn  路  4Comments