Skip to content

Commit 4e21acd

Browse files
committed
Add signature_type='query' for OAuth1Session to support BIGSdb GET requests
1 parent e607e89 commit 4e21acd

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

microSALT/utils/pubmlst/authentication.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def get_new_session_token(self, db: str):
6363
client_secret=consumer_secret,
6464
resource_owner_key=access_token,
6565
resource_owner_secret=access_secret,
66+
signature_type="query",
6667
)
6768

6869
response = session.get(url, headers={"User-Agent": "BIGSdb API downloader"})

microSALT/utils/pubmlst/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def _make_request(
112112
client_secret=self.consumer_secret,
113113
resource_owner_key=token,
114114
resource_owner_secret=secret,
115+
signature_type="query",
115116
)
116117

117118
response = session.request(method.value, url)

microSALT/utils/pubmlst/get_credentials.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ def get_new_access_token(
2323
) -> tuple[str, str]:
2424
"""Obtain a new access token and secret.
2525
26-
BIGSdb OAuth endpoints require GET (not POST), so we use oauth.get()
27-
directly rather than requests-oauthlib's fetch_request_token/fetch_access_token
28-
helpers, which both default to POST.
26+
BIGSdb OAuth endpoints require GET (not POST), and expect OAuth parameters
27+
as query string parameters (not in the Authorization header), so we use
28+
signature_type='query' and oauth.get() directly.
2929
"""
3030
# Step 1: GET request token
31-
oauth = OAuth1Session(client_id, client_secret=client_secret, callback_uri="oob")
31+
oauth = OAuth1Session(
32+
client_id, client_secret=client_secret, callback_uri="oob", signature_type="query"
33+
)
3234
response = oauth.get(f"{base_api}/db/{db}/oauth/get_request_token")
3335
if not response.ok:
3436
print(f"Error obtaining request token: {response.text}")
@@ -51,6 +53,7 @@ def get_new_access_token(
5153
resource_owner_key=request_token,
5254
resource_owner_secret=request_secret,
5355
verifier=verifier,
56+
signature_type="query",
5457
)
5558
response = oauth.get(f"{base_api}/db/{db}/oauth/get_access_token")
5659
if not response.ok:

0 commit comments

Comments
 (0)