Use Access Grants to Access Resources#
AccessGrantSession
#
The inrupt-client-accessgrant
module includes AccessGrantSession
that builds an authenticated Session object using both Access Grants
and an OpenID-based session. (For more information on OpenID-based
sessions, see Session Management.)
For example, once ExamplePrinter app receives an access grant, it can use the grant to access the resource(s) for printing; namely:
Fetch the access grant:
Session myOpenIDSession = OpenIdSession.ofIdToken(idToken); // idToken of ExamplePrinter URI MY_ESS_ACCESS_GRANT_SERVICE = URI.create("https://vc.{MY_ESS_DOMAIN}.com"); AccessGrantClient accessgrantclient = new AccessGrantClient(MY_ESS_ACCESS_GRANT_SERVICE) .session(myOpenIDSession); // the authenticated session of ExamplePrinter AccessGrant grant = accessgrantclient.fetch(URI.create("https://vc.{ESS DOMAIN}/vc/xxxxxx..."));
Create a AccessGrantSession using both the ExamplePrinter’s OpenID Session and the access grant:
Session agSession = AccessGrantSession.ofAccessGrant(myOpenIDSession, grant);
Create a SolidClient (or SolidSyncClient) using this AccessGrantSession:
SolidClient client = SolidClient.getClient().session(agSession);
Use the .send() method to access the non-RDF resources and .read() method to read RDF resources.