Page MenuHomeSoftware Heritage

client: Add OpenID Connect bearer token authentication
ClosedPublic

Authored by anlambert on Mon, Mar 23, 6:15 PM.

Details

Summary

By providing a refresh token, obtained with the swh auth login
command to the new authenticate method of the client, all emitted requests
will be authenticated using a bearer token sent in headers.

Example of use:

from swh.web.client import WebAPIClient

REFRESH_TOKEN = '.......'  # Use "swh auth login" command to get it

client = WebAPIClient()
client.authenticate(REFRESH_TOKEN)

# All requests to the Web API will be authenticated
resp = client.get('swh:1:rev:aafb16d69fd30ff58afdd69036a26047f3aebdc6')

Depends on D2861

Related to T1927

Diff Detail

Repository
rDWCLI Web client
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Mon, Mar 23, 6:15 PM

Looks like I need to update my local version of mypy as I did no get those errors.

swh/web/client/client.py:432: error: Unsupported right operand type for in ("Optional[Dict[str, Any]]")
swh/web/client/client.py:433: error: Value of type "Optional[Dict[str, Any]]" is not indexable
swh/web/client/client.py:435: error: Unsupported target for indexed assignment
swh/web/client/client.py:438: error: Unsupported right operand type for in ("Optional[Dict[str, Any]]")
anlambert updated this revision to Diff 10222.Mon, Mar 23, 6:25 PM

Update: Fix mypy 0.770 errors

zack accepted this revision.Tue, Mar 24, 9:30 AM
This revision is now accepted and ready to land.Tue, Mar 24, 9:30 AM
anlambert edited the summary of this revision. (Show Details)Tue, Mar 24, 12:04 PM
anlambert updated this revision to Diff 10231.Tue, Mar 24, 12:06 PM

Update commit message