# Path: social/backends/oauth.py
# class BaseOAuth1(OAuthAuth):
#     """Consumer based mechanism OAuth authentication, fill the needed
#     parameters to communicate properly with authentication service.
# 
#         AUTHORIZATION_URL       Authorization service url
#         REQUEST_TOKEN_URL       Request token URL
#         ACCESS_TOKEN_URL        Access token URL
#     """
#     AUTHORIZATION_URL = ''
#     REQUEST_TOKEN_URL = ''
#     REQUEST_TOKEN_METHOD = 'GET'
#     OAUTH_TOKEN_PARAMETER_NAME = 'oauth_token'
#     REDIRECT_URI_PARAMETER_NAME = 'redirect_uri'
#     ACCESS_TOKEN_URL = ''
# 
#     def auth_url(self):
#         """Return redirect url"""
#         token = self.unauthorized_token()
#         name = self.name + 'unauthorized_token_name'
#         tokens = self.strategy.session_get(name, []) + [token]
#         self.strategy.session_set(name, tokens)
#         return self.oauth_authorization_request(token)
# 
#     def process_error(self, data):
#         if 'oauth_problem' in data:
#             if data['oauth_problem'] == 'user_refused':
#                 raise AuthCanceled(self, 'User refused the access')
#             raise AuthUnknownError(self, 'Error was ' + data['oauth_problem'])
# 
#     def auth_complete(self, *args, **kwargs):
#         """Return user, might be logged in"""
#         # Multiple unauthorized tokens are supported (see #521)
#         self.process_error(self.data)
#         name = self.name + 'unauthorized_token_name'
#         token = None
#         unauthed_tokens = self.strategy.session_get(name, [])
#         if not unauthed_tokens:
#             raise AuthTokenError(self, 'Missing unauthorized token')
#         token_param_name = self.OAUTH_TOKEN_PARAMETER_NAME
#         data_token = self.data.get(token_param_name, 'no-token')
#         for unauthed_token in unauthed_tokens:
#             orig_unauthed_token = unauthed_token
#             if not isinstance(unauthed_token, dict):
#                 unauthed_token = parse_qs(unauthed_token)
#             if unauthed_token.get(token_param_name) == data_token:
#                 self.strategy.session_set(name, list(
#                     set(unauthed_tokens) -
#                     set([orig_unauthed_token]))
#                 )
#                 token = unauthed_token
#                 break
#         else:
#             raise AuthTokenError(self, 'Incorrect tokens')
# 
#         try:
#             access_token = self.access_token(token)
#         except HTTPError as err:
#             if err.response.status_code == 400:
#                 raise AuthCanceled(self)
#             else:
#                 raise
#         return self.do_auth(access_token, *args, **kwargs)
# 
#     def do_auth(self, access_token, *args, **kwargs):
#         """Finish the auth process once the access_token was retrieved"""
#         data = self.user_data(access_token)
#         if data is not None and 'access_token' not in data:
#             data['access_token'] = access_token
#         kwargs.update({'response': data, 'backend': self})
#         return self.strategy.authenticate(*args, **kwargs)
# 
#     def unauthorized_token(self):
#         """Return request for unauthorized token (first stage)"""
#         params = self.request_token_extra_arguments()
#         params.update(self.get_scope_argument())
#         key, secret = self.get_key_and_secret()
#         response = self.request(self.REQUEST_TOKEN_URL,
#                                 params=params,
#                                 auth=OAuth1(key, secret,
#                                             callback_uri=self.redirect_uri),
#                                 method=self.REQUEST_TOKEN_METHOD)
#         return response.content
# 
#     def oauth_authorization_request(self, token):
#         """Generate OAuth request to authorize token."""
#         if not isinstance(token, dict):
#             token = parse_qs(token)
#         params = self.auth_extra_arguments() or {}
#         params.update(self.get_scope_argument())
#         params[self.OAUTH_TOKEN_PARAMETER_NAME] = token.get(
#             self.OAUTH_TOKEN_PARAMETER_NAME
#         )
#         params[self.REDIRECT_URI_PARAMETER_NAME] = self.redirect_uri
#         return self.AUTHORIZATION_URL + '?' + urlencode(params)
# 
#     def oauth_auth(self, token=None, oauth_verifier=None,
#                    signature_type=SIGNATURE_TYPE_AUTH_HEADER):
#         key, secret = self.get_key_and_secret()
#         oauth_verifier = oauth_verifier or self.data.get('oauth_verifier')
#         token = token or {}
#         return OAuth1(key, secret,
#                       resource_owner_key=token.get('oauth_token'),
#                       resource_owner_secret=token.get('oauth_token_secret'),
#                       callback_uri=self.redirect_uri,
#                       verifier=oauth_verifier,
#                       signature_type=signature_type)
# 
#     def oauth_request(self, token, url, params=None, method='GET'):
#         """Generate OAuth request, setups callback url"""
#         return self.request(url, method=method, params=params,
#                             auth=self.oauth_auth(token))
# 
#     def access_token(self, token):
#         """Return request for access token value"""
#         return self.get_querystring(self.ACCESS_TOKEN_URL,
#                                     auth=self.oauth_auth(token),
#                                     method=self.ACCESS_TOKEN_METHOD)


from social.backends.oauth import BaseOAuth1
"""
Trello OAuth support.

This contribution adds support for Trello OAuth service. The settings
SOCIAL_AUTH_TRELLO_KEY and SOCIAL_AUTH_TRELLO_SECRET must be defined with
the values given by `https://trello.com/1/appKey/generate`.

Extended permissions are supported by defining TRELLO_EXTENDED_PERMISSIONS
setting, it must be a list of values to request.

By default account id and token expiration time are stored in extra_data
field, check OAuthBackend class for details on how to extend it.

"""




# Path: social/backends/oauth.py
# class BaseOAuth1(OAuthAuth):
#     """Consumer based mechanism OAuth authentication, fill the needed
#     parameters to communicate properly with authentication service.
# 
#         AUTHORIZATION_URL       Authorization service url
#         REQUEST_TOKEN_URL       Request token URL
#         ACCESS_TOKEN_URL        Access token URL
#     """
#     AUTHORIZATION_URL = ''
#     REQUEST_TOKEN_URL = ''
#     REQUEST_TOKEN_METHOD = 'GET'
#     OAUTH_TOKEN_PARAMETER_NAME = 'oauth_token'
#     REDIRECT_URI_PARAMETER_NAME = 'redirect_uri'
#     ACCESS_TOKEN_URL = ''
# 
#     def auth_url(self):
#         """Return redirect url"""
#         token = self.unauthorized_token()
#         name = self.name + 'unauthorized_token_name'
#         tokens = self.strategy.session_get(name, []) + [token]
#         self.strategy.session_set(name, tokens)
#         return self.oauth_authorization_request(token)
# 
#     def process_error(self, data):
#         if 'oauth_problem' in data:
#             if data['oauth_problem'] == 'user_refused':
#                 raise AuthCanceled(self, 'User refused the access')
#             raise AuthUnknownError(self, 'Error was ' + data['oauth_problem'])
# 
#     def auth_complete(self, *args, **kwargs):
#         """Return user, might be logged in"""
#         # Multiple unauthorized tokens are supported (see #521)
#         self.process_error(self.data)
#         name = self.name + 'unauthorized_token_name'
#         token = None
#         unauthed_tokens = self.strategy.session_get(name, [])
#         if not unauthed_tokens:
#             raise AuthTokenError(self, 'Missing unauthorized token')
#         token_param_name = self.OAUTH_TOKEN_PARAMETER_NAME
#         data_token = self.data.get(token_param_name, 'no-token')
#         for unauthed_token in unauthed_tokens:
#             orig_unauthed_token = unauthed_token
#             if not isinstance(unauthed_token, dict):
#                 unauthed_token = parse_qs(unauthed_token)
#             if unauthed_token.get(token_param_name) == data_token:
#                 self.strategy.session_set(name, list(
#                     set(unauthed_tokens) -
#                     set([orig_unauthed_token]))
#                 )
#                 token = unauthed_token
#                 break
#         else:
#             raise AuthTokenError(self, 'Incorrect tokens')
# 
#         try:
#             access_token = self.access_token(token)
#         except HTTPError as err:
#             if err.response.status_code == 400:
#                 raise AuthCanceled(self)
#             else:
#                 raise
#         return self.do_auth(access_token, *args, **kwargs)
# 
#     def do_auth(self, access_token, *args, **kwargs):
#         """Finish the auth process once the access_token was retrieved"""
#         data = self.user_data(access_token)
#         if data is not None and 'access_token' not in data:
#             data['access_token'] = access_token
#         kwargs.update({'response': data, 'backend': self})
#         return self.strategy.authenticate(*args, **kwargs)
# 
#     def unauthorized_token(self):
#         """Return request for unauthorized token (first stage)"""
#         params = self.request_token_extra_arguments()
#         params.update(self.get_scope_argument())
#         key, secret = self.get_key_and_secret()
#         response = self.request(self.REQUEST_TOKEN_URL,
#                                 params=params,
#                                 auth=OAuth1(key, secret,
#                                             callback_uri=self.redirect_uri),
#                                 method=self.REQUEST_TOKEN_METHOD)
#         return response.content
# 
#     def oauth_authorization_request(self, token):
#         """Generate OAuth request to authorize token."""
#         if not isinstance(token, dict):
#             token = parse_qs(token)
#         params = self.auth_extra_arguments() or {}
#         params.update(self.get_scope_argument())
#         params[self.OAUTH_TOKEN_PARAMETER_NAME] = token.get(
#             self.OAUTH_TOKEN_PARAMETER_NAME
#         )
#         params[self.REDIRECT_URI_PARAMETER_NAME] = self.redirect_uri
#         return self.AUTHORIZATION_URL + '?' + urlencode(params)
# 
#     def oauth_auth(self, token=None, oauth_verifier=None,
#                    signature_type=SIGNATURE_TYPE_AUTH_HEADER):
#         key, secret = self.get_key_and_secret()
#         oauth_verifier = oauth_verifier or self.data.get('oauth_verifier')
#         token = token or {}
#         return OAuth1(key, secret,
#                       resource_owner_key=token.get('oauth_token'),
#                       resource_owner_secret=token.get('oauth_token_secret'),
#                       callback_uri=self.redirect_uri,
#                       verifier=oauth_verifier,
#                       signature_type=signature_type)
# 
#     def oauth_request(self, token, url, params=None, method='GET'):
#         """Generate OAuth request, setups callback url"""
#         return self.request(url, method=method, params=params,
#                             auth=self.oauth_auth(token))
# 
#     def access_token(self, token):
#         """Return request for access token value"""
#         return self.get_querystring(self.ACCESS_TOKEN_URL,
#                                     auth=self.oauth_auth(token),
#                                     method=self.ACCESS_TOKEN_METHOD)


# Path: social/backends/trello.py
from social.backends.oauth import BaseOAuth1

"""
Trello OAuth support.

This contribution adds support for Trello OAuth service. The settings
SOCIAL_AUTH_TRELLO_KEY and SOCIAL_AUTH_TRELLO_SECRET must be defined with
the values given by `https://trello.com/1/appKey/generate`.

Extended permissions are supported by defining TRELLO_EXTENDED_PERMISSIONS
setting, it must be a list of values to request.

By default account id and token expiration time are stored in extra_data
field, check OAuthBackend class for details on how to extend it.

"""




class TrelloOAuth(BaseOAuth1):