Page MenuHomeSoftware Heritage

client: Add OpenID Connect bearer token authentication
ClosedPublic

Authored by anlambert on Mar 23 2020, 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
Branch
webapiclient-auth
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 11297
Build 17082: tox-on-jenkinsJenkins
Build 17081: arc lint + arc unit

Event Timeline

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]]")

Update: Fix mypy 0.770 errors

This revision is now accepted and ready to land.Mar 24 2020, 9:30 AM