Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions flask_oauthlib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,6 @@ def __init__(
self.oauth = oauth
self.name = name

if (not consumer_key or not consumer_secret) and not app_key:
raise TypeError(
'OAuthRemoteApp requires consumer key and secret'
)

self._base_url = base_url
self._request_token_url = request_token_url
self._access_token_url = access_token_url
Expand All @@ -251,6 +246,26 @@ def __init__(
self.app_key = app_key
self.encoding = encoding

# Check for required authentication information.
# Skip this check if app_key is specified, since the information is
# specified in the Flask config, instead.
if not app_key:
req_params = self.request_token_params or {}
if req_params.get("signature_method") == oauthlib.oauth1.SIGNATURE_RSA:
# check for consumer_key and rsa_key
rsa_key = req_params.get("rsa_key")
if not consumer_key or not rsa_key:
raise TypeError(
"OAuthRemoteApp with RSA authentication requires "
"consumer key and rsa key"
)
else:
# check for consumer_key and consumer_secret
if not consumer_key or not consumer_secret:
raise TypeError(
"OAuthRemoteApp requires consumer key and secret"
)

@cached_property
def base_url(self):
return self._get_property('base_url')
Expand Down Expand Up @@ -321,7 +336,8 @@ def make_client(self, token=None):
params["resource_owner_secret"] = token[1]

client = oauthlib.oauth1.Client(
self.consumer_key, self.consumer_secret,
client_key=self.consumer_key,
client_secret=self.consumer_secret,
**params
)

Expand Down