Retrieve user profile information using solid node client?

hey Jeff, I hopped on this. But I haven’t the correct setup I guess. I’ ll attach my html, my js and the error message. Can you see what I missed ? (perhaps I’ll have to setup express… setup webpack… work with rdflib-save… the require already doesn’t work…)

<!DOCTYPE html>
<html lang = "de">
<meta charset = "utf-8">
<title>print name</title>
  <h5>output goes to console</h5>
 <script src = "index.js"></script>
<!-- <img src="favicon.ico" onload="execCode()" > -->
<!-- <p id = "something"></p> -->
const $rdf = require('rdflib');                                                 
const {SolidNodeClient} = require("solid-node-client");                         
const client = new SolidNodeClient();                                           
const store = $rdf.graph();                                                     
const fetcher = $rdf.fetcher(store,{fetch:client.fetch.bind(client)});          
const me = store.sym(''); 
const profile = me.doc()                                                        
const VCARD = $rdf.Namespace('');           
const FOAF = $rdf.Namespace('');                      
fetcher.load(profile).then( ()=>{                                                    
  let name = store.any(me, VCARD("fn")) || store.any(me, FOAF("name"));         
  console.log("user name: ", name.value);                                       


@ewingson - Solid Node Client is a client for Nodejs (command-line and console-based scripts). It is not intended to work in a browser althoug it can work in conjunction with a browser in an Electron environment,

okay… I now have done npm install rdflib --save in the dir of the js. how do I execute the script ?

node scriptname

works. !! thanx !!

1 Like

Thanks! I can successfully access my name. But the code you provided in Can not access node solid development server localhost returns “Can not read property value of null”
My code:

const { SolidNodeClient } = require("solid-node-client");
const client = new SolidNodeClient();
const $rdf = require("rdflib");
const store = $rdf.graph();
const fetcher = $rdf.fetcher(store,{fetch:client.fetch.bind(client)});
const FoaF = $rdf.Namespace('');
const VCARD = $rdf.Namespace("");
const pim = $rdf.Namespace('');
router.get("/loginSSI", async function (req, res) {
  try {
    console.log("try ");
    let ses = await client.login({
      idp: YOUR_IDENTITY_PROVIDER, // e.g.
      username: "username",
      password: "password",
    const me = $rdf.sym(ses.webId);
    console.log("me: ", me);
    const profile = $rdf.sym(ses.webId).doc();
    console.log("profile: ", profile);
    await fetcher.load(profile);
    let myPrefs = store.any(me,pim("preferencesFile"));
    await fetcher.load(myPrefs);
    let mbox = store.any( me , FoaF('mbox'));
    console.log("mbox: ",mbox.value); // can not read property 'value' of null
    let token = uuidv4();
    req.session.token = token; => {
  } catch (error) {

I think you first need to see if you can login from the command-line. Try this:

const {SolidNodeClient} = require("solid-node-client");                         
const client  = new SolidNodeClient();                                          
async function login(credentials){                                              
  console.log('logging in ...');                                                
  let session = await client.login(credentials);                                
  if( session.isLoggedIn ) {                                                    
    console.log(`logged in as <${session.WebID}>`);                             
    return session;                                                             
  else {                                                                        
    console.log(`Could not login to <${credentials.idp}>`);                     
  idp: "YOUR_IDENTITY_PROVIDER", // e.g.             
  username: "username",                                                         
  password: "password",                                                         

You wrote :


I am sorry, I can not debug your server or your express. I can help you with solid-node-client. But please run the script I provided and tell me the results.

Oh sorry. the login function is working fine. It returns my webId.

You were able to login to your local NSS?

No. I am using my solid Community Pod. I’ve tried with my local NSS but was unsuccessful.

You tried the script I provided using the login credentials for your local NSS? What were the results? (results of the script, I don’t care what the server log is)

Sorry if I didn’t understand you correctly. I tried the script you provided with my solidCommunity pod and it returns my webId.

Isn’t your aim to use solid node client to access your local NSS pod?

Yeah. But due to some issues, I am accessing solidCommunity instead of my local NSS temporarily.

Please try the script I provided with your local NSS details. It is the only way to find out what the problem is.

Ok. I’ll get back to you soon. Thanks.

Good luck!

I ran your script. It returns

TypeError: Cannot read property '‘isLoggedIn’ of null

I have added information on how I installed local NSS on my laptop.In my pc I can use my local pod to login in existing solid app.But when I use in docker “https://localhost:8443” it returns above error. In docker I am using node v10. I can’t upgrade my node due to dependency issue.

I can run NSS fine in node 12. You should troubleshoot with NSS. Neither rdflib nor solid-node-client can run in node 10 so if you stay with node 10, you simply can not use those libraries. What OS are you using?

You might also want to investigate NVM which lets you easily switch back and forth between node versions.