I am receiving the following token from an application and servicing it at an endpoint in the Flask.
I have the following issue. I want to access the token which is stored in the header of the https packet.
With the code below, I get the a string like this, "Basic veliq89#ei"
. I do not want to have the Basic
in the token_string. I am not sure on how to just access the token value which is veliq89#ei
.
token_string = request.environ.get('HTTP_AUTHORIZATION')
Authorization headers usually include method of authentication as the first word in the header value. You simply have to split the header value and get the last part as the token value
token_header = request.environ.get('HTTP_AUTHORIZATION') # "Basic veliq89#ei"
token = token_header.split(maxsplit=1)[1] # "veliq89#ei"