Solid-ldflex authenticated requests

Hello everyone!

First of all: I have recently started reading about solid, linked data and so on (I am an undergrad student in Software Engineering) so please, excuse me if I say something incorrect!.

I’m currently developing an Android App which uses Solid to retrieve and store user’s friends (aka: foaf:knows).

The application doesn’t communicate itself with the pod by any means, instead, it uses a REST API (built with nodejs, express and solid-ldflex to fetch the user’s friends from his pod).

The point is that I am able to log the user in his pod (with solid-auth-cli) and fetch its friends (I know this is public data so authentication is not really needed here) but I am absolutely lost about how to add a friend using solid-ldflex, something that, I know its posible as stated here: SOCOM Tutorial Slides - LDflex

await [].add('foaf:givenName' , 'Julian')

These slides show a way to modify the user’s given name (which I guess is an authenticated operation) but don’t really provide any insight about the authentication part.

In the worst case scenario (that is, I can’t use solid-ldflex) I won’t really have a problem using basic SPARQL queries (but again, I don’t know how to run authenticated operations) :

INSERT DATA { <user_webid> <> <friend_webid> . }


I need a way to combine solid-ldflex and solid-auth-cli to add a friend to an authenticated user’s pod in a server side enviroment running nodejs.

Thanks for reading me!

Hi Ramón, welcome to the Solid forum! Unfortunately I think solid-ldflex automatically uses solid-auth-client, so I don’t think it will work with solid-auth-cli (but maybe @jeffz, the author of solid-auth-cli, can confirm). That said, the README of solid-auth-cli mentions that it’s been deprecated and replaced by solid-node-client, which I presume it’s good to be aware of.

Also note that basic SPARQL queries aren’t your only alternative to solid-ldflex. For example, I work on Inrupt’s solid-client library, which is more extensively documented and also supports Node.js. Inrupt also has solid-client-authn-node, which allows you to authenticate a user and then provides a fetch function that can make authenticated requests, in case you really just want to run raw SPARQL queries. (And I think Jeff’s solid-node-client supports this too?)

Thanks @Vincent, I am aware that solid-auth-cli has been deprecated, I use it because I found its documentation to be more straighforward (and because my app is just a prototype I don’t think there is any risk).
I guess its a good moment to migrate to solid-client-authn-node! Could you provide and example of raw SPARQL with the fetch() function? (I couldn’t find anything in the documentation).

Off the top of my head, it’d be something like:

session.fetch("https://your.pod/resource", {
    method: "PATCH",
    headers: {
        "Content-Type": "application/sparql-update",
    body: "INSERT DATA { <user_webid> <> <friend_webid> . }",

(But I’m not super familiar with SPARQL so might need some tweaking.)

Best place for more information about that is just the Solid spec I think, as this is exactly what libraries try not to expose you to :slight_smile:

At the moment, solid-auth-cli should work on NSS servers so if you are only working on POC, it should be fine. Both it and solid-node-client support SPARQL patch but you must pass in a $rdf parser object.

Could’nt you use webapps facilities and develop your app in js ? It works really great on Android

Sorry,could I put in a word? I also use nodejs+express to developing back-end for an app, and i had install the library solid-node-client. I met some difficutl when i authentication for NSS-Style Pods,i had added the error and code in reply:

But authentication for ESS-Style Pods is worked well.
Thanks for reading me!

Well yes, I could try, but in this particular situation I would like to use a more native approach, which, in turn, would both help me to 1) understand how Solid authentication works and 2) force me to develop a REST API to abstract the use of Solid (so it’ll become much easier to maintain and extend in the future).

I would also like to develop a java/kotlin package for this specific use case (interaction with solid pods as an storage/database system) although right now I don’t really have any idea about how I’ll do it.

Why so much work when you could just use the existing libraries and tools? Well, I think that most android developers would happily integrate Solid into their applications if there was a simple and straightforward way to do it, something that (IMO) would greatly help to kick-start the adoption of this technology.

@wenjingli-qa - I have responded to you in another thread. I am investigating the issue and will report back.