Ë
    +Ñ¦hŽ  ã                   ó’   — d dl mZ d dlmZ d dlmZ d dlmZ dZdZ	dZ
dZd	Z	 	 dd
d
dd
d
d
d
dd
dœ	d„Z ed„ «      Z G d„ de«      Zy
)é    )Úg)ÚWebApplicationClient)Ú
LocalProxy)ÚOAuth2ConsumerBlueprintz%Ryan Schaffer <schaffer.ry@gmail.com>Úauth_headerÚqueryÚbodyzZoho-oauthtokenNF)	ÚscopeÚredirect_urlÚofflineÚredirect_toÚ	login_urlÚsession_classÚstorageÚreprompt_consentÚrule_kwargsc       	         ó  ‡— |xs dg}d}t        | t        ¬«      }i }|rdnd|d<   |	rd|d<   t        d	t        | ||||d
d|||||||
¬«      Šd‰j                  d<   d‰j                  d<   ‰j
                  ˆfd„«       }‰S )a§  
    Make a blueprint for authenticating with Zoho using OAuth 2. This requires
    a client ID and client secret from Zoho. You should either pass them to
    this constructor, or make sure that your Flask application config defines
    them, using the variables :envvar:`ZOHO_OAUTH_CLIENT_ID` and
    :envvar:`ZOHO_OAUTH_CLIENT_SECRET`.
    IMPORTANT: Configuring the base_url is not supported in this config.

    Args:
        client_id (str): The client ID for your application on Zoho.
        client_secret (str): The client secret for your application on Zoho
        scope (list, optional): list of scopes (str) for the OAuth token
        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 ``/zoho``
        authorized_url (str, optional): the URL path for the ``authorized`` view.
            Defaults to ``/zoho/authorized``.
        session_class (class, optional): The class to use for creating a
            Requests session. Defaults to
            :class:`~flask_dance.consumer.requests.OAuth2Session`.
        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`.
        offline (bool): Whether to request `offline access`
            for the OAuth token. Defaults to False
        reprompt_consent (bool): If True, force Zoho to re-prompt the user
            for their consent, even if the user has already given their
            consent. Defaults to False.
        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.
    zZohoCRM.users.allzhttps://www.zohoapis.com/)Ú
token_typer   ÚonlineÚaccess_typeÚconsentÚpromptÚzohoz(https://accounts.zoho.com/oauth/v2/tokenz'https://accounts.zoho.com/oauth/v2/auth)Ú	client_idÚclient_secretÚclientr
   Úbase_urlÚ	token_urlÚauthorization_urlÚauthorization_url_paramsr   r   r   r   r   r   ÚZOHO_OAUTH_CLIENT_IDr   ÚZOHO_OAUTH_CLIENT_SECRETr   c                  ó0   •— ‰ j                   t        _        y ©N)Úsessionr   Úflask_dance_zoho)Úzoho_bps   €úP/var/www/timesheet/venv/lib/python3.12/site-packages/flask_dance/contrib/zoho.pyÚset_applocal_sessionz1make_zoho_blueprint.<locals>.set_applocal_session`   s   ø€ à$Ÿ_™_ŒÕó    )ÚZohoWebClientÚZOHO_TOKEN_HEADERr   Ú__name__Úfrom_configÚbefore_app_request)r   r   r
   r   r   r   r   r   r   r   r   r   r   r    r)   r'   s                  @r(   Úmake_zoho_blueprintr0      sÄ   ø€ ðh Ò*Ð)Ð*€EØ*€HÜ˜9Ô1BÔC€FØ!ÐÙ;B©iÈÐ˜]Ñ+ÙØ-6Ð  Ñ*Ü%ØÜØØ#ØØØØ<ØCØ!9Ø!ØØØ#ØØô!€Gð& (>€G×Ñ˜Ñ$Ø+E€G×Ñ˜Ñ(à×Ñó-ó  ð-ð €Nr*   c                  ó"   — t         j                  S r$   )r   r&   © r*   r(   ú<lambda>r3   g   s   € œ!×,Ñ,€ r*   c                   ó<   — e Zd ZdZed„ «       Z	 dd„Zedd„«       Zy)r+   zJ
    Remove the requirement that token_types adhere to OAuth Standard
    c                 óV   — d| j                   d| j                  t        | j                  iS )NÚBearerÚMAC)Ú_add_bearer_tokenÚ_add_mac_tokenr,   Ú_add_zoho_token)Úselfs    r(   Útoken_typeszZohoWebClient.token_typeso   s/   € ð �d×,Ñ,Ø�4×&Ñ&Ü˜t×3Ñ3ð
ð 	
r*   Nc                 óD   — | j                  | j                  |«      }|||fS )zYAdd a zoho token to the request uri, body or authorization header. follows bearer pattern)Úprepare_zoho_headersÚaccess_token)r;   ÚuriÚhttp_methodr	   ÚheadersÚtoken_placements         r(   r:   zZohoWebClient._add_zoho_tokenw   s)   € ð ×+Ñ+¨D×,=Ñ,=¸wÓGˆØ�G˜TÐ!Ð!r*   c                 óF   — |xs i }dj                  t        | ¬«      |d<   |S )zÒAdd a `Zoho Token`_ to the request URI.
        Recommended method of passing bearer tokens.

        Authorization: Zoho-oauthtoken h480djs93hd8

        .. _`Zoho-oauthtoken Token`: custom zoho token
        z{token_header} {token})Útoken_headerÚtokenÚAuthorization)Úformatr,   )rF   rB   s     r(   r>   z"ZohoWebClient.prepare_zoho_headers~   s4   € ð ’-˜RˆØ#;×#BÑ#BÜ*°%ð $Có $
ˆ�Ñ ð ˆr*   )ÚGETNNNr$   )	r-   Ú
__module__Ú__qualname__Ú__doc__Úpropertyr<   r:   Ústaticmethodr>   r2   r*   r(   r+   r+   j   s;   „ ñð ñ
ó ð
ð PTó"ð òó ñr*   r+   )NN)Úflaskr   Ú/oauthlib.oauth2.rfc6749.clients.web_applicationr   Úwerkzeug.localr   Úflask_dance.consumerr   Ú__maintainer__ÚAUTH_HEADERÚ	URI_QUERYÚBODYr,   r0   r   r+   r2   r*   r(   ú<module>rW      sw   ðÝ Ý PÝ %å 8à8€à€Ø€	Ø€Ø%Ð ð ØðUð ØØØØØØØØôUñp Ñ,Ó-€ô!Ð(õ !r*   