o
    Dfb                     @   s8   d dl Z d dlZd dlmZ dd Zdd Zdd ZdS )	    N
to_unicodec                 C   s8   t | tttfrddd | D S | du r| S t| S )z5Convert a list of scopes to a space separated string. c                 S      g | ]}t |qS  r   .0sr   r   T/home/ubuntu/webapp/venv/lib/python3.10/site-packages/authlib/oauth2/rfc6749/util.py
<listcomp>	       z!list_to_scope.<locals>.<listcomp>N)
isinstancesettuplelistjoinr   scoper   r   r
   list_to_scope   s
   r   c                 C   s6   t | tttfrdd | D S | du rdS |   S )z5Convert a space separated string to a list of scopes.c                 S   r   r   r   r   r   r   r
   r      r   z!scope_to_list.<locals>.<listcomp>N)r   r   r   r   stripsplitr   r   r   r
   scope_to_list   s
   r   c              	   C   s   |  d}|rd|vrdS |d d\}}| dkrdS z	tt|}W n tjtfy3   Y dS w d|v rD|dd\}}||fS |d fS )NAuthorizationr   )NN   basic:)	getr   lowerr   base64	b64decodebinasciiError	TypeError)headersauth	auth_type
auth_tokenqueryusernamepasswordr   r   r
   extract_basic_authorization   s   
r*   )r   r    authlib.common.encodingr   r   r   r*   r   r   r   r
   <module>   s    		