What is oauthlib?
Applications need a correctly encoded authorization request before a provider can ask users to sign in.
Applications need a correctly encoded authorization request before a provider can ask users to sign in.
Apart from marked quotes, everything on this page comes from our own test run.
How we tested oauthlib
We ran oauthlib v4.0.0 on (UTC) in an isolated sandbox: Ubuntu under WSL2. Networking was switched off, so nothing was downloaded or sent during the test. The test ran as an unprivileged user with an empty home directory.
Sandbox checks recorded before the run, all passed: network disabled, home directory blocked, secrets blocked, writes limited to the test workspace.
Setup as recorded: WSL2 sandbox: no network, read-only root, nobody user; local copy of the installed release.
- The input file
example.py(224 bytes) was placed in an empty workspace. - We ran
bin/test example.py. It exited with code 0. - We kept the exact output (113 bytes) and compared it with the input byte for byte.
- The terminal session was recorded (6.59 seconds).
bin/test is defined by the test definition in our repository (config/curation/oauthlib-4.0.0.json), shown below as it stood when this page was built. The script itself is not part of the hashed test record, unlike the input, output and command above.
#!/usr/bin/python3 -I
import contextlib
import io
import sys
import time
from urllib.parse import parse_qs, urlsplit
START = time.perf_counter()
sys.path.insert(0, "/tmp/ws")
OUT = []
def check(label, test):
try:
ok = bool(test())
except BaseException as exc:
ok = False
print("check %r raised %s" % (label, type(exc).__name__), file=sys.stderr)
OUT.append((ok, label))
def raises(error, action):
try:
action()
except error:
return True
return False
N = {"__name__": "curated_example"}
try:
with contextlib.redirect_stdout(io.StringIO()):
exec(compile(open(sys.argv[1], encoding="utf-8").read(), sys.argv[1], "exec"), N)
except BaseException as exc:
print("Example failed: " + type(exc).__name__, file=sys.stderr)
check('Client id included', lambda: parse_qs(urlsplit(N["uri"]).query)["client_id"] == ["public-demo"])
check('State preserved', lambda: parse_qs(urlsplit(N["uri"]).query)["state"] == ["demo-state"])
check('Callback encoded', lambda: parse_qs(urlsplit(N["uri"]).query)["redirect_uri"] == [N["back"]])
check('Code flow requested', lambda: parse_qs(urlsplit(N["uri"]).query)["response_type"] == ["code"])
for ok, label in OUT:
print(("PASS " if ok else "FAIL ") + label)
print("%d/%d passed in %.2f s" % (sum(o for o, _ in OUT), len(OUT), time.perf_counter() - START))
What we saw
What we tried: Run the local documented API example: Client id included, State preserved, Callback encoded, Code flow requested.
What went in: 8 lines of text (224 bytes).
What came out: 5 lines of text (113 bytes).
Exact recorded input and output. Invisible characters are written out (for example \x1b is the escape character) so you can see them.
from oauthlib.oauth2 import (
WebApplicationClient as WC)
url="https://demo.test/auth"
back="https://demo.test/back"
client=WC("public-demo")
uri=client.prepare_request_uri(
url, state="demo-state",
redirect_uri=back)
PASS Client id included
PASS State preserved
PASS Callback encoded
PASS Code flow requested
4/4 passed in 0.05 s
Measured result
- Input size
- 224 bytes
- Output size
- 113 bytes
- Sandbox run time
- 7.91 seconds: the whole isolated sandbox run, including sandbox start-up. This is not the tool's own processing time.
- Demo recording length
- 6.59 seconds
Recorded measurement: 4 of 4 README checks passed in 0.05 seconds.
Limits of this test
Use it to graft OAuth client support onto your favorite HTTP library, or provide support onto your favourite web framework.
This record covers one input, one version (v4.0.0) and one platform (Ubuntu under WSL2). It is not a speed benchmark: the sandbox time includes start-up. We did not run it on Windows or macOS here, so results there may differ.
Is oauthlib a fit for you?
- Check further if your input goes beyond our sample: the limit quoted above comes from the project itself.
- Check further if you need it on Windows: this record covers Ubuntu under WSL2 only.
Questions this test answers
Did we test oauthlib on Windows?
No. This record ran on Ubuntu under WSL2. It does not show how oauthlib behaves in a Windows console.
Which version did we test, and when?
oauthlib v4.0.0, on (UTC).
Did the test need internet access?
No. The sandbox had networking switched off for the whole run.
What does oauthlib not handle?
Our single input does not probe this. The project names its own limit, quoted under Limits of this test; inputs like that need their own test.
Watch the test
Pressing play loads the YouTube player from youtube-nocookie.com; YouTube (Google) then applies its own privacy policy. Nothing is loaded from YouTube before you press play. Privacy
Transcript
Build a login request locally.
It's a Python framework for building OAuth requests without depending on a particular HTTP library or web framework. It has 2,986 stars on GitHub and a three-clause BSD license.
Here is what it gives you: one, client id attached; two, state preserved; three, callback encoded.
We ran the README example in a sandbox with no network: 4 checks in all.
Result: 4 of 4 checks passed in 0.05 seconds.
Our verdict: it works. One honest limit: we built one authorization URL only; no login, token exchange or live provider was tested.
Full test results are in the Tools link on our profile.
Test records
Each test keeps the code shown in its video. Code THRQST leads here; you can also search any code on Find a code.
| Code | Tested | Version | Platform | Result |
|---|---|---|---|---|
| THRQST | v4.0.0 | Ubuntu under WSL2 | see record |
Official links
Related tools we tested
- cachetools: see record
- filelock: see record
- fsspec: see record
- httpx: see record
- more-itertools: see record
- multidict: see record
License and attribution
- BSD-3-Clause — oauthlib by Idan Gazit and contributors (BSD-3-Clause)
Rights holder: Idan Gazit and contributors. Permission: use_modify_distribute License source ↗ - LicenseRef-RepoProof-Owned — RepoProof
Rights holder: RepoProof. Permission: use_modify_distribute License source ↗
Covers 6 assets: demo input, demo output, demo recording, input frame, output frame, demo extra checks json. - LicenseRef-RepoProof-Owned — RepoProof capture of github.com/oauthlib/oauthlib
Rights holder: RepoProof. Permission: use_modify_distribute License source ↗
Covers 3 assets: demo extra github page png, demo extra github stars png, demo extra github json.
Production note
AI-assisted script and synthetic narration; demo recorded by our automated test workflow.
Page text is assembled from the recorded test data. Sentences taken from the tool's README are marked as quotes.