Adding new friends


#1

Hi! Back again.

I was finally able to list other friends’ friends without any trouble. Now my question is how do I add new friends. Currently I have this method in my rdf service:

addFriend(friendWebId) {
   let insertions = [];
    let deletions = [];
    try {
        const doc = $rdf.sym(this.session.webId.split('#')[0]);
        const add = $rdf.st($rdf.sym(this.session.webId), $rdf.sym(FOAF('knows')), $rdf.sym(friendWebId), doc);
        insertions.push(add);

        this.updateManager.update(deletions, insertions, (uri, success, message) => {
            if (!success) {
                console.log('Error: ' + message);
            }
        });
    } catch (error) {
        console.log(`Error adding data: ${error}`);
    }
}

Thought it was pretty simple. Either it isn’t adding the friend correctly or my list of friends in the app isn’t updating properly. I’ve seen some methods that use the UpdateManager but I dont know exactly how that goes. Any ideas?

Thanks!! :heart::relaxed:


#2

Have you added the origin of your web app to the list of trusted apps in your profile?

You should get to a step while logging in that asks you to give permission to your web application. If you haven’t seen it, you might want to check the trustedApplicationsPane, it’s available through your profile, it’s the pane that has a stylized A as it’s icon.


#3

The error definitely mentions “403 - Origin Unauthorized”. Which means that @megoth’s suggestion is the first place to look. The status code from the server may not always be the best explanation for what went wrong, but it is always the first place to look.


#4

@megoth is most likely right, however sometimes if you’ve logged in a few different places with different webIDs, they can get crossed up. If I hit a 401 or 403 the first thing I try is to clear full application cache, and sometimes even go to the provider and clear cookies there as well (since the local cookie will aid in the login process and we want a fully fresh login). Then re-login. I’d say about 1/3 of the time this fixes the 401/403 errors.


#5

I will try look it up there as I had already tried clearing the cache and still came up with that. I didn’t know pods had this feature.

Thanks!!!


#6

Up until last week, they didn’t :-). Last week solid.community went from version 4.x to version 5.x of Node-Solid-Server. One of the most major changes was that 5.x implements what the specifications have required - that BOTH the user and the app need to have permission. So the same script two weeks ago would not have produced this error.