# Path: pyoauth/_compat.py
# def unquote_plus(v):
# 
# Path: pyoauth/constants.py
# OPENID_MODE_CHECK_AUTHENTICATION = "check_authentication"
# 
# HEADER_CONTENT_TYPE = "content-type"
# 
# HTTP_POST = b("POST")
# 
# OAUTH_VALUE_CALLBACK_OOB = b("oob")
# 
# OAUTH_PARAM_TOKEN = "oauth_token"
# 
# OAUTH_PARAM_VERIFIER = "oauth_verifier"
# 
# OPENID_MODE_CHECKID_SETUP = "checkid_setup"
# 
# OPENID_AX_MODE_FETCH_REQUEST = "fetch_request"
# 
# Path: pyoauth/url.py
# def url_add_query(url, query, predicate=None):
#     """
#     Adds additional query parameters to a URL while preserving existing ones.
# 
#     The URL will be normalized according to the OAuth specification with the
#     exception that the URL fragment is preserved.
# 
#     :param url:
#         The URL to add the additional query parameters to.
#     :param query:
#         The additional query parameters as a dictionary object or a query
#         string.
#     :param predicate:
#         A callback that will be called for each query parameter and should
#         return ``False`` or a falsy value if that parameter should not be
#         included. By default, all query parameters are included. The function
#         takes the following method signature::
# 
#             def predicate(name, value):
#                 return is_name_allowed(name) and is_value_allowed(value)
#     :returns:
#         A normalized URL with the fragment and existing query parameters
#         preserved and with the extra query parameters added.
#     """
#     scheme, netloc, path, params, query_s, fragment = urlparse_normalized(url)
# 
#     query_d = query_add(query_s, query)
#     query_s = urlencode_s(query_d, predicate)
#     return urlunparse((scheme, netloc, path, params, query_s, fragment))
# 
# Path: pyoauth/http.py
# class RequestAdapter(object):
#     """Adaptor HTTP Request class.
# 
#     Framework implementers can subclass this class and must use it with
#     the client methods for them to work.
#     """
#     def __init__(self, method, url, body=None, headers=None):
#         self._method = method.upper()
#         self._url = url
#         self._body = body
#         self._headers = headers
# 
#     @property
#     def method(self):
#         """
#         Determines the HTTP request method.
#         """
#         return self._method
# 
#     @property
#     def url(self):
#         """
#         Determines the URL.
#         """
#         return self._url
# 
#     @property
#     def payload(self):
#         """
#         Payload for the request.
#         """
#         return self._body
# 
#     @property
#     def body(self):
#         """Payload for the request."""
#         return self._body
# 
#     @property
#     def content(self):
#         """Payload for the request."""
#         return self._body
# 
#     @property
#     def headers(self):
#         """Dictionary of headers."""
#         return self._headers
# 
# CONTENT_TYPE_FORM_URLENCODED = b("application/x-www-form-urlencoded")


import logging
from urllib import urlencode
from mom.functional import select_dict, map_dict
from pyoauth._compat import urljoin
from pyoauth.constants import OPENID_MODE_CHECK_AUTHENTICATION, \
    HEADER_CONTENT_TYPE, HTTP_POST, OAUTH_VALUE_CALLBACK_OOB, \
    OAUTH_PARAM_TOKEN, OAUTH_PARAM_VERIFIER, OPENID_MODE_CHECKID_SETUP, \
    OPENID_AX_MODE_FETCH_REQUEST
from pyoauth.url import url_add_query
from pyoauth.http import RequestAdapter, CONTENT_TYPE_FORM_URLENCODED
    def _on_temporary_credentials(self, authenticate, credentials):
        # Obtain the temporary credentials from the response
        # and save them temporarily in a session cookie.
        self.adapter_set_credentials_cookie(credentials)
        if authenticate:
            # Redirects to the authentication URL.
            url = self.oauth_client.get_authentication_url(credentials)
        else:
            # Redirects to the authorization URL.
            url = self.oauth_client.get_authorization_url(credentials)
        self.adapter_redirect(url)

    def get_authenticated_user(self, callback, realm=None):
        """
        Gets the OAuth authorized user and access token on callback.

        This method should be called from the handler for your registered
        OAuth callback URL to complete the registration process. We call
        callback with the authenticated user, which in addition to standard
        attributes like 'name' includes the 'access_key' attribute, which
        contains the OAuth access you can use to make authorized requests
        to this service on behalf of the user.

        :param callback:
            The callback that will be called upon successful authorization
            with the user object as its first argument.
        :param realm:
            The realm for the authorization header.
        """
        oauth_token = self.adapter_request_get(OAUTH_PARAM_TOKEN)

# Path: pyoauth/_compat.py
# def unquote_plus(v):
# 
# Path: pyoauth/constants.py
# OPENID_MODE_CHECK_AUTHENTICATION = "check_authentication"
# 
# HEADER_CONTENT_TYPE = "content-type"
# 
# HTTP_POST = b("POST")
# 
# OAUTH_VALUE_CALLBACK_OOB = b("oob")
# 
# OAUTH_PARAM_TOKEN = "oauth_token"
# 
# OAUTH_PARAM_VERIFIER = "oauth_verifier"
# 
# OPENID_MODE_CHECKID_SETUP = "checkid_setup"
# 
# OPENID_AX_MODE_FETCH_REQUEST = "fetch_request"
# 
# Path: pyoauth/url.py
# def url_add_query(url, query, predicate=None):
#     """
#     Adds additional query parameters to a URL while preserving existing ones.
# 
#     The URL will be normalized according to the OAuth specification with the
#     exception that the URL fragment is preserved.
# 
#     :param url:
#         The URL to add the additional query parameters to.
#     :param query:
#         The additional query parameters as a dictionary object or a query
#         string.
#     :param predicate:
#         A callback that will be called for each query parameter and should
#         return ``False`` or a falsy value if that parameter should not be
#         included. By default, all query parameters are included. The function
#         takes the following method signature::
# 
#             def predicate(name, value):
#                 return is_name_allowed(name) and is_value_allowed(value)
#     :returns:
#         A normalized URL with the fragment and existing query parameters
#         preserved and with the extra query parameters added.
#     """
#     scheme, netloc, path, params, query_s, fragment = urlparse_normalized(url)
# 
#     query_d = query_add(query_s, query)
#     query_s = urlencode_s(query_d, predicate)
#     return urlunparse((scheme, netloc, path, params, query_s, fragment))
# 
# Path: pyoauth/http.py
# class RequestAdapter(object):
#     """Adaptor HTTP Request class.
# 
#     Framework implementers can subclass this class and must use it with
#     the client methods for them to work.
#     """
#     def __init__(self, method, url, body=None, headers=None):
#         self._method = method.upper()
#         self._url = url
#         self._body = body
#         self._headers = headers
# 
#     @property
#     def method(self):
#         """
#         Determines the HTTP request method.
#         """
#         return self._method
# 
#     @property
#     def url(self):
#         """
#         Determines the URL.
#         """
#         return self._url
# 
#     @property
#     def payload(self):
#         """
#         Payload for the request.
#         """
#         return self._body
# 
#     @property
#     def body(self):
#         """Payload for the request."""
#         return self._body
# 
#     @property
#     def content(self):
#         """Payload for the request."""
#         return self._body
# 
#     @property
#     def headers(self):
#         """Dictionary of headers."""
#         return self._headers
# 
# CONTENT_TYPE_FORM_URLENCODED = b("application/x-www-form-urlencoded")


# Path: pyoauth/oauth1/client/mixins.py
import logging
from urllib import urlencode
from mom.functional import select_dict, map_dict
from pyoauth._compat import urljoin
from pyoauth.constants import OPENID_MODE_CHECK_AUTHENTICATION, \
    HEADER_CONTENT_TYPE, HTTP_POST, OAUTH_VALUE_CALLBACK_OOB, \
    OAUTH_PARAM_TOKEN, OAUTH_PARAM_VERIFIER, OPENID_MODE_CHECKID_SETUP, \
    OPENID_AX_MODE_FETCH_REQUEST
from pyoauth.url import url_add_query
from pyoauth.http import RequestAdapter, CONTENT_TYPE_FORM_URLENCODED

    def _on_temporary_credentials(self, authenticate, credentials):
        # Obtain the temporary credentials from the response
        # and save them temporarily in a session cookie.
        self.adapter_set_credentials_cookie(credentials)
        if authenticate:
            # Redirects to the authentication URL.
            url = self.oauth_client.get_authentication_url(credentials)
        else:
            # Redirects to the authorization URL.
            url = self.oauth_client.get_authorization_url(credentials)
        self.adapter_redirect(url)

    def get_authenticated_user(self, callback, realm=None):
        """
        Gets the OAuth authorized user and access token on callback.

        This method should be called from the handler for your registered
        OAuth callback URL to complete the registration process. We call
        callback with the authenticated user, which in addition to standard
        attributes like 'name' includes the 'access_key' attribute, which
        contains the OAuth access you can use to make authorized requests
        to this service on behalf of the user.

        :param callback:
            The callback that will be called upon successful authorization
            with the user object as its first argument.
        :param realm:
            The realm for the authorization header.
        """
        oauth_token = self.adapter_request_get(OAUTH_PARAM_TOKEN)

        oauth_verifier = self.adapter_request_get(OAUTH_PARAM_VERIFIER)