
    D6i}                         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      ]/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/flask_dance/contrib/reddit.pyr   zRedditOAuth2Session.__init__   s5    $)&) &*^^%>%>%TBT\"    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"WT^^-E-EWPV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+&-II/*%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   