o
    &zh                     @   s   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d	efd
dZG dd deZG dd deZdd Zdd ZdS )    N)reverse)DeviceApplicationServer)Server)context)app_settings)get_adapter)OAuthLibRequestValidatorreturnc                 C   s
   t dS )N@   )secretstoken_urlsafe)request r   d/var/www/html/kangema/venv/lib/python3.10/site-packages/allauth/idp/oidc/internal/oauthlib/server.pygenerate_token   s   
r   c                          e Zd Z fddZ  ZS )OAuthLibServerc                    s"   t  jdtt tjd| d S )N)token_generatorrequest_validatortoken_expires_inr   )super__init__r   r   r   ACCESS_TOKEN_EXPIRES_IN)selfkwargs	__class__r   r   r      s   
zOAuthLibServer.__init____name__
__module____qualname__r   __classcell__r   r   r   r   r          r   c                       r   )DeviceOAuthLibServerc                    s>   t jtd}t jt ||d tjdd d tj	| _
d S )Nzidp:oidc:device_authorizationz?code={user_code}c                   S   s
   t   S N)r   generate_user_coder   r   r   r   <lambda>,   s   
 z/DeviceOAuthLibServer.__init__.<locals>.<lambda>)r   verification_uriverification_uri_completeintervaluser_code_generator)r   r   build_absolute_urir   r   r   r   r   DEVICE_CODE_INTERVALDEVICE_CODE_EXPIRES_IN_expires_in)r   r'   r   r   r   r   #   s   zDeviceOAuthLibServer.__init__r   r   r   r   r   r#   "   r"   r#   c                  K   s   t di | S )Nr   )r   )r   r   r   r   
get_server1   s   r/   c                   C   s   t  S r$   )r#   r   r   r   r   get_device_server5   s   r0   )r   django.urlsr   !oauthlib.oauth2.rfc8628.endpointsr   oauthlib.openidr   allauth.corer   allauth.idp.oidcr   allauth.idp.oidc.adapterr   4allauth.idp.oidc.internal.oauthlib.request_validatorr   strr   r   r#   r/   r0   r   r   r   r   <module>   s    