authlib
authlib copied to clipboard
_render method called twice causing duplicate OAuth parameters when using Auth1Auth plugin for httpx
Describe the bug
In the authlib library, I noticed that the _render method is called twice in the following code block when using the OAuth1Auth plugin for httpx. This results in duplicated OAuth parameters for the URL, which may cause unexpected behavior.
uri, headers, body = self._render(uri, headers, body, oauth_params)
sig = self.get_oauth_signature(method, uri, headers, body)
oauth_params.append(('oauth_signature', sig))
uri, headers, body = self._render(uri, headers, body, oauth_params)
I am using the OAuth1Auth plugin with httpx as follows:
OAuth1Auth(
consumer_key,
"...",
token=...,
token_secret=...,
rsa_key=...,
signature_method=...,
signature_type=SIGNATURE_TYPE_QUERY,
)
Error Stacks
The request is incomplete or incorrect;
Response: oauth_problem=parameter_rejected
oauth_parameters_rejected=oauth_nonce%3DEBDB7Xv5JUgkH3Qj6djMHFQjaainjU
To Reproduce
- Install the
authliblibrary - Set up the
OAuth1Authwith the required credentials plugin forhttpx - Call the endpoint that utilizes the above code snippet
- Observe the duplicated OAuth parameters in the generated URL
Expected behavior
The _render method should be called only once, and the OAuth parameters should not be duplicated in the URL.
Environment:
- OS: -
- Python Version: 3.8
- Authlib Version: "^1.2.0"