Skip to main content

Solid OIDC Client

A client to use Solid-OIDC authentication.

Status

This is in beta: use with care. Expect bugs and breaking changes even with minor version updates.

Currently following features are missing:

  • refreshing expired tokens
  • persistent client id and client secret

Contributing

Contributions are welcome. These could be additional features, bug fixes, automated testing, better documentation or any other contribution.

Example app

Here is a simple example that authenticates users with this library and makes authenticated requests in the python backend: https://github.com/Otto-AA/solid-flask

Installation

pip install solid_oidc_client

Usage

Following code guides you through the authentication process:

from solid_oidc_client import SolidOidcClient, SolidAuthSession, MemStore

# create a client instance
solid_oidc_client = SolidOidcClient(storage=MemStore())
OAUTH_CALLBACK_URI = '/oauth/callback'

# register this application with the issuer (client_id and client_secret are currently only stored in memory, regardless of the previous storage)
# the redirect url in this case is /oauth/callback
solid_oidc_client.register_client('https://login.inrupt.com/', [OAUTH_CALLBACK_URI])

# initiate a login by redirecting the user to this url
# store the path you want to redirect the user after the login ('/')
login_url = solid_oidc_client.create_login_uri('/', OAUTH_CALLBACK_URI)

# wait for the user to login with their identity provider
# listen on /oauth/callback
# then get code and state from the query params
code = flask.request.args['code']
state = flask.request.args['state']

# and use them to get an authentication session
# internally this will store an access token and key for dpop
session = solid_oidc_client.finish_login(
    code=code,
    state=state,
    callback_uri=OAUTH_CALLBACK_URI,
)

# use this session to make authenticated requests
private_url = 'https://pod.example.org/private/secret.txt'
auth_headers = session.get_auth_headers(private_url, 'GET')
res = requests.get(url=tested_url, headers=auth_headers)
print(res.text)


# optionally serialize and deserialize the sessions to store them as a string client/server side
flask.session['auth'] = session.serialize()
session = SolidAuthSession.deserialize(flask.session['auth'])

Acknowledgments

This is based on solid-flask by Rai.

Metadata

Release files for solid-oidc-client 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for solid-oidc-client 0.0.4
File Size Uploaded
solid_oidc_client-0.0.4.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for solid-oidc-client 0.0.4
File Interpreter ABI Platform
solid_oidc_client-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / solid_oidc_client-0.0.4.tar.gz

Download URL solid_oidc_client-0.0.4.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1e7143a5d2f7e4623b736d3b414848574163815b4e30b6c62896c8f63dc1020b
BLAKE2b-256 checksum
How to use checksums
01bd4c7693fce0ecd93f3e7685e688b4d91b3abd83fe6fcb795ab0eca146b424
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / solid_oidc_client-0.0.4-py3-none-any.whl

Download URL solid_oidc_client-0.0.4-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ade3ae58c46f03b1ed1a093cb41412894bd49eaef7da0fcd5de18c3f3d50e63
BLAKE2b-256 checksum
How to use checksums
f72c69eaaf98ca17fbaeba4e7c16dd1466211c5a0a01fd82be12b5032bb442f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page