Skip to content

Commit 8e7cbb3

Browse files
author
derwentx
committed
better error handling
1 parent b110e3b commit 8e7cbb3

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

setup.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
setup(
2424
name="wordpress-api",
2525
version=VERSION,
26-
description="A Python wrapper for the Wordpress and WooCommerce REST APIs with oAuth1a 3leg support",
26+
description=(
27+
"A Python wrapper for the Wordpress and WooCommerce REST APIs "
28+
"with oAuth1a 3leg support"
29+
),
2730
long_description=README,
28-
author="Claudio Sanches @ Automattic , forked by Derwent @ Laserphile",
29-
url="https://github.com/woocommerce/wc-api-python",
31+
author="Claudio Sanches @ Automattic, forked by Derwent @ Laserphile",
32+
url="https://github.com/derwentx/wp-api-python",
3033
license="MIT License",
3134
packages=[
3235
"wordpress"

wordpress/auth.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,17 +275,25 @@ def discover_auth(self):
275275
response = self.requester.request('GET', discovery_url)
276276
response_json = response.json()
277277

278-
assert \
279-
response_json['authentication'], \
280-
"resopnse should include location of authentication resources, resopnse: %s" \
281-
% UrlUtils.beautify_response(response)
278+
if not 'authentication' in response_json:
279+
raise UserWarning(
280+
(
281+
"Resopnse does not include location of authentication resources.\n"
282+
"Resopnse: %s\n"
283+
"Please check you have configured the Wordpress OAuth1 plugin correctly."
284+
) % (response)
285+
)
282286

283287
self._authentication = response_json['authentication']
284288

285289
return self._authentication
286290

287291
def get_request_token(self):
288-
""" Uses the request authentication link to get an oauth_token for requesting an access token """
292+
"""
293+
Uses the request authentication link to get an oauth_token for
294+
requesting an access token
295+
"""
296+
289297
assert self.consumer_key, "need a valid consumer_key for this step"
290298

291299
params = self.get_params()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy