Ë
    +Ñ¦h}  ã                   ó’   — d dl mZ d dlmZ d dlmZ d dlmZm	Z	 dZ
de› �Z G d„ de	«      Z	 	 dd
dd	d	d	d	d	d	d	d	dœ
d„Z ed„ «      Zy	)é    )Úg)Ú
LocalProxy)Ú__version__)ÚOAuth2ConsumerBlueprintÚOAuth2SessionzSergey Storchay <r8@r8.com.ua>zFlask-Dance/c                   ó(   ‡ — e Zd Zˆ fd„Zˆ fd„Zˆ xZS )ÚRedditOAuth2Sessionc                 óz   •— t        ‰| �  |i |¤Ž | j                  j                  xs t        | j
                  d<   y )Nz
User-Agent)ÚsuperÚ__init__Ú	blueprintÚ
user_agentÚDEFAULT_USER_AGENTÚheaders©ÚselfÚargsÚkwargsÚ	__class__s      €úR/var/www/timesheet/venv/lib/python3.12/site-packages/flask_dance/contrib/reddit.pyr   zRedditOAuth2Session.__init__   s5   ø€ Ü‰Ñ˜$Ð) &Ò)ð &*§^¡^×%>Ñ%>Ò%TÔBTˆ�‰�\Ò"ó    c                 óN   •— t        ‰| �  |d| j                  j                  i|¤ŽS )NÚ	client_id)r   Úfetch_tokenr   r   r   s      €r   r   zRedditOAuth2Session.fetch_token   s(   ø€ ä‰wÑ"ÈÐW¨T¯^©^×-EÑ-EÐWÐPVÑWÐWr   )Ú__name__Ú
__module__Ú__qualname__r   r   Ú__classcell__)r   s   @r   r	   r	      s   ø„ ôU÷Xð Xr   r	   NÚidentityF)
ÚscopeÚ	permanentÚredirect_urlÚredirect_toÚ	login_urlÚauthorized_urlÚsession_classÚstorager   Úrule_kwargsc       
         óÚ   ‡— i }|rd|d<   t        dt        f| ||dd|dd|||||xs t        |	|dœŽŠd‰j                  d	<   d
‰j                  d<   |
‰_        ‰j
                  ˆfd„«       }‰S )a  
    Make a blueprint for authenticating with Reddit using OAuth 2. This requires
    a client ID and client secret from Reddit. You should either pass them to
    this constructor, or make sure that your Flask application config defines
    them, using the variables :envvar:`REDDIT_OAUTH_CLIENT_ID` and
    :envvar:`REDDIT_OAUTH_CLIENT_SECRET`.

    Args:
        client_id (str): The client ID for your application on Reddit.
        client_secret (str): The client secret for your application on Reddit
        scope (str, optional): space-separated list of scopes for the OAuth token
            Defaults to ``identity``
        permanent (bool, optional): Whether to request permanent access token.
            Defaults to False, access will be valid for 1 hour
        redirect_url (str): the URL to redirect to after the authentication
            dance is complete
        redirect_to (str): if ``redirect_url`` is not defined, the name of the
            view to redirect to after the authentication dance is complete.
            The actual URL will be determined by :func:`flask.url_for`
        login_url (str, optional): the URL path for the ``login`` view.
            Defaults to ``/reddit``
        authorized_url (str, optional): the URL path for the ``authorized`` view.
            Defaults to ``/reddit/authorized``.
        session_class (class, optional): The class to use for creating a
            Requests session. Defaults to
            :class:`~flask_dance.contrib.reddit.RedditOAuth2Session`.
        storage: A token storage class, or an instance of a token storage
            class, to use for this blueprint. Defaults to
            :class:`~flask_dance.consumer.storage.session.SessionStorage`.
        user_agent (str, optional): User agent for the requests to Reddit API.
            Defaults to ``Flask-Dance/{{version}}``.
        rule_kwargs (dict, optional): Additional arguments that should be passed when adding
            the login and authorized routes. Defaults to ``None``.

    :rtype: :class:`~flask_dance.consumer.OAuth2ConsumerBlueprint`
    :returns: A :doc:`blueprint <flask:blueprints>` to attach to your Flask app.
    r!   ÚdurationÚredditzhttps://oauth.reddit.com/z'https://www.reddit.com/api/v1/authorizez*https://www.reddit.com/api/v1/access_token)r   Úclient_secretr    Úbase_urlÚauthorization_urlÚauthorization_url_paramsÚ	token_urlÚauto_refresh_urlr"   r#   r$   r%   r&   r'   r(   ÚREDDIT_OAUTH_CLIENT_IDr   ÚREDDIT_OAUTH_CLIENT_SECRETr,   c                  ó0   •— ‰ j                   t        _        y ©N)Úsessionr   Úflask_dance_reddit)Ú	reddit_bps   €r   Úset_applocal_sessionz3make_reddit_blueprint.<locals>.set_applocal_sessionj   s   ø€ à(×0Ñ0ŒÕr   )r   r   r	   Úfrom_configr   Úbefore_app_request)r   r,   r    r!   r"   r#   r$   r%   r&   r'   r   r(   r/   r9   r8   s                 @r   Úmake_reddit_blueprintr<      s¯   ø€ ðh  "ÐÙØ/:Ð  Ñ,ä'ØÜðð Ø#ØØ,ØCØ!9Ø>ØEØ!ØØØ%Ø#Ò:Ô':ØØò#€Ið( *B€I×Ñ˜+Ñ&Ø-I€I×Ñ˜/Ñ*à%€IÔà×!Ñ!ó1ó "ð1ð Ðr   c                  ó"   — t         j                  S r5   )r   r7   © r   r   ú<lambda>r?   q   s   € œA×0Ñ0€ r   )NN)Úflaskr   Úwerkzeug.localr   Úflask_dancer   Ú_flask_dance_versionÚflask_dance.consumerr   r   Ú__maintainer__r   r	   r<   r+   r>   r   r   ú<module>rF      sw   ðÝ Ý %å ;ß Gà1€ð $Ð$8Ð#9Ð:Ð ô	X˜-ô 	Xð ØðUð ØØØØØØØØØôUñp 
Ñ0Ó	1�r   