Python get authorization header
12 Python code examples are found related to "
get authorization header".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: oauth2_client.py From gcs-oauth2-boto-plugin with Apache License 2.0 | 6 votes |
def GetAuthorizationHeader(self): """Gets the access token HTTP authorization header value. Returns: The value of an Authorization HTTP header that authenticates requests with an OAuth2 access token. """ return 'Bearer %s' % self.GetAccessToken().token
Example 2
Source File: auth.py From flask-apscheduler with Apache License 2.0 | 6 votes |
def get_authorization_header(): """ Return request's 'Authorization:' header as a two-tuple of (type, info). """ header = request.environ.get('HTTP_AUTHORIZATION') if not header: return None header = wsgi_to_bytes(header) try: auth_type, auth_info = header.split(None, 1) auth_type = auth_type.lower() except ValueError: return None return auth_type, auth_info
Example 3
Source File: middleware.py From arches with GNU Affero General Public License v3.0 | 5 votes |
def get_authorization_header(self, request): """ Return request's 'Authorization:' header, as a bytestring. Hide some test client ickyness where the header can be unicode. """ auth = request.META.get("HTTP_AUTHORIZATION", b"").replace("Bearer ", "") if isinstance(auth, text_type): # Work around django test client oddness auth = auth.encode(HTTP_HEADER_ENCODING) return auth
Example 4
Source File: credentials.py From PyAPNs2 with MIT License | 5 votes |
def get_authorization_header(self, topic: Optional[str]) -> Optional[str]: return None # Credentials subclass for certificate authentication
Example 5
Source File: backend.py From asap-authentication-python with MIT License | 5 votes |
def get_authorization_header(self, request=None): if request is None: request = current_req return request.headers.get('AUTHORIZATION', '')
Example 6
Source File: auth.py From azure-cosmos-python with MIT License | 5 votes |
def GetAuthorizationHeader(cosmos_client, verb, path, resource_id_or_fullname, is_name_based, resource_type, headers): """Gets the authorization header. :param cosmos_client.CosmosClient cosmos_client: :param str verb: :param str path: :param str resource_id_or_fullname: :param str resource_type: :param dict headers: :return: The authorization headers. :rtype: dict """ # In the AuthorizationToken generation logic, lower casing of ResourceID is required as rest of the fields are lower cased # Lower casing should not be done for named based "ID", which should be used as is if resource_id_or_fullname is not None and not is_name_based: resource_id_or_fullname = resource_id_or_fullname.lower() if cosmos_client.master_key: return __GetAuthorizationTokenUsingMasterKey(verb, resource_id_or_fullname, resource_type, headers, cosmos_client.master_key) elif cosmos_client.resource_tokens: return __GetAuthorizationTokenUsingResourceTokens( cosmos_client.resource_tokens, path, resource_id_or_fullname)
Example 7
Source File: authorization_header.py From bii-server with MIT License | 5 votes |
def get_authorization_header_value(self): '''Get from the request the header of http basic auth: http://en.wikipedia.org/wiki/Basic_access_authentication''' auth_type = self.get_authorization_type() if request.headers.get("Authorization", None) != None: auth_line = request.headers.get("Authorization", None) if not auth_line.startswith("%s " % auth_type): raise self.get_invalid_header_response() return auth_line[len(auth_type) + 1:] else: return None
Example 8
Source File: authentication.py From Dailyfresh-B2C with Apache License 2.0 | 5 votes |
def get_authorization_header(request): """ Return request's 'Authorization:' header, as a bytestring. Hide some test client ickyness where the header can be unicode. """ auth = request.META.get('HTTP_AUTHORIZATION', b'') if isinstance(auth, text_type): # Work around django test client oddness auth = auth.encode(HTTP_HEADER_ENCODING) return auth
Example 9
Source File: authentication.py From kel-api with Apache License 2.0 | 5 votes |
def get_authorization_header(request): auth = request.META.get("HTTP_AUTHORIZATION", b"") if isinstance(auth, six.string_types): auth = auth.encode("iso-8859-1") return auth
Example 10
Source File: basic_auth.py From flytekit with Apache License 2.0 | 5 votes |
def get_basic_authorization_header(client_id, client_secret): """ This function transforms the client id and the client secret into a header that conforms with http basic auth. It joins the id and the secret with a : then base64 encodes it, then adds the appropriate text. :param Text client_id: :param Text client_secret: :rtype: Text """ concated = "{}:{}".format(client_id, client_secret) return "Basic {}".format(_base64.b64encode(concated.encode(_utf_8)).decode(_utf_8))
Example 11
Source File: utils.py From django-jwt-auth with MIT License | 5 votes |
def get_authorization_header(request): """ Return request's 'Authorization:' header, as a bytestring. From: https://github.com/tomchristie/django-rest-framework/blob/master/rest_framework/authentication.py """ auth = request.META.get('HTTP_AUTHORIZATION', b'') if isinstance(auth, type('')): # Work around django test client oddness auth = auth.encode('iso-8859-1') return auth
Example 12
Source File: authentication.py From esdc-ce with Apache License 2.0 | 5 votes |
def get_authorization_header(request): """ Return request's 'Authorization:' header, as a bytestring. Hide some test client ickiness where the header can be unicode. """ auth = request.META.get('HTTP_AUTHORIZATION', b'') if isinstance(auth, text_type): # Work around django test client oddness auth = auth.encode(HTTP_HEADER_ENCODING) return auth