Adjust OAuth to work better

This commit is contained in:
Edward Betts 2023-11-25 19:59:28 +00:00
parent b6cc79291b
commit 8901831568

View file

@ -146,6 +146,8 @@ def start_oauth() -> Response:
flask.session["owner_key"] = fetch_response.get("oauth_token")
flask.session["owner_secret"] = fetch_response.get("oauth_token_secret")
assert flask.session["owner_key"] and flask.session["owner_secret"]
base_authorization_url = f"https://{wiki_hostname}/wiki/Special:OAuth/authorize"
authorization_url = oauth.authorization_url(
base_authorization_url, oauth_consumer_key=client_key
@ -162,8 +164,8 @@ def oauth_callback() -> werkzeug.wrappers.response.Response:
oauth = OAuth1Session(
client_key,
client_secret=client_secret,
resource_owner_key=flask.session["owner_key"],
resource_owner_secret=flask.session["owner_secret"],
resource_owner_key=flask.session.get("owner_key"),
resource_owner_secret=flask.session.get("owner_secret"),
)
oauth_response = oauth.parse_authorization_response(flask.request.url)
@ -343,8 +345,8 @@ def api_hits() -> werkzeug.wrappers.response.Response:
@app.route("/api/1/valid_hit")
def api_valid_hit() -> werkzeug.wrappers.response.Response:
"""Return canidates for the given article title."""
link_from = flask.request.args.get("link_from")
link_to = flask.request.args.get("link_to")
link_from = flask.request.args["link_from"]
link_to = flask.request.args["link_to"]
try:
diff, replacement = get_diff(link_to, link_from, None)