
    D6i_              
           d Z ddlmZ ddlmZ ddlmZ ddlmZ dZ	 G d de      Z
	 	 dd	d	d	d	d	e
d	d	d
dZ ed       Zy	)z'Blueprint for connecting to Twitch API.    )g)
LocalProxy)OAuth2ConsumerBlueprint)OAuth2Sessionz,Kerry Hatcher <kerry.hatcher@protonmail.com>c                   "     e Zd ZdZ fdZ xZS )ClientIdHeaderOAuth2Sessionzd
    https://blog.twitch.tv/en/2016/05/05/client-id-required-for-kraken-api-calls-afbb8e95f843/
    c                 V    t        |   |i | | j                  | j                  d<   y )Nz	client-id)super__init__	client_idheaders)selfargskwargs	__class__s      ]/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/flask_dance/contrib/twitch.pyr   z$ClientIdHeaderOAuth2Session.__init__   s'    $)&)$(NN[!    )__name__
__module____qualname____doc__r   __classcell__)r   s   @r   r   r      s    3 3r   r   N)scoperedirect_urlredirect_to	login_urlauthorized_urlsession_classstoragerule_kwargsc                   t        dt        | ||dddddi|||||||	      dj                  d	<   d
j                  d<   j                  _        j
                  j                  d_        j                  fd       }
S )a  Make a blueprint for authenticating with Twitch using OAuth 2.

    This requires a client ID and client secret from Twitch.
    You should either pass them to this constructor, or make sure that your
    Flask application config defines them, using the variables
    :envvar:`TWITCH_OAUTH_CLIENT_ID` and :envvar:`TWITCH_OAUTH_CLIENT_SECRET`.

    Args:
        client_id (str): The client ID for your application on Twitch.
            Defaults to app config "TWITCH_OAUTH_CLIENT_ID".
        client_secret (str): The client Secret for your application on Twitch.
            Defaults to app config "TWITCH_OAUTH_CLIENT_SECRET".
        scope (list, optional): Comma-separated list of scopes for the OAuth token.
            Defaults to None.
        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 ``/twitch``
        authorized_url (str, optional): the URL path for the ``authorized`` view.
            Defaults to ``/twitch/authorized``.
        session_class (class, optional): The class to use for creating a
            Requests session. Defaults to
            :class:`~flask_dance.contrib.twitch.ClientIdHeaderOAuth2Session`.
        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`.
        rule_kwargs (dict, optional): Additional arguments that should be passed when adding
            the login and authorized routes. Defaults to ``None``.

    Returns:
        :class:`~flask_dance.consumer.OAuth2ConsumerBlueprint` A :doc:`blueprint <flask:blueprints>` to attach to your Flask app.
    twitchzhttps://api.twitch.tv/helix/z%https://id.twitch.tv/oauth2/authorizez!https://id.twitch.tv/oauth2/tokeninclude_client_idT)r   client_secretr   base_urlauthorization_url	token_urltoken_url_paramsr   r   r   r   r   r   r    TWITCH_OAUTH_CLIENT_IDr   TWITCH_OAUTH_CLIENT_SECRETr$   )r   r$   c                  0     j                   t        _        y N)sessionr   flask_dance_twitch)	twitch_bps   r   set_applocal_sessionz3make_twitch_blueprint.<locals>.set_applocal_sessiond   s    (00r   )	r   r   from_configr'   auto_refresh_urlr   r$   auto_refresh_kwargsbefore_app_request)r   r$   r   r   r   r   r   r   r   r    r0   r/   s              @r   make_twitch_blueprintr5      s    ` (#/A5-t4!%#!I& *BI+&-II/* "+!4!4I(("00%I!
 !!1 "1 r   c                  "    t         j                  S r,   )r   r.    r   r   <lambda>r8   k   s    A00 r   )NN)r   flaskr   werkzeug.localr   flask_dance.consumerr   flask_dance.consumer.requestsr   __maintainer__r   r5   r"   r7   r   r   <module>r>      sa    -  % 8 7?3- 3 R -Rj 
0	1r   