1

I am using Flask to generate REST API.

I want to check authorization header which is sent by mobile apps.

I am using below code

from flask import request
cookie_data = request.headers.get('auth_token')

It is working on local machine, but when i host it on server it is not working, when i debug it gives null value. The difference is, on my local machine flask version = 0.10.1 python =2.7.8 on server flask = 0.10.1, python= 2.6.9

0

2 Answers 2

2

I doubt the Python version is the issue; it probably has something to do with server configuration. Specifically, "auth_token" is not a standard HTTP header, so your server may be filtering it out from the request before it gets to Flask.

You may want to test with one of the standard headers, such as "Authorization". If this works, then it's likely that the problem is the nonstandard header.

Sign up to request clarification or add additional context in comments.

3 Comments

if i want more custom header, how do i add
really thanks for your answer, it save my time. i just figure out how only alphanumeric characters or '-' are allowed.
Thanks a ton. This answer helped me after a whole day of hair pulling frustration, just because one of my HTTP Headers was user_id :)
2

Turns out that only alphanumeric characters or '-' are allowed.

Any headers not conforming these will be ignored.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.