nodeSolidServer/solid-auth-client

Receiving the message: "401 - Not authenticated" to the logged-in agent

jrleles opened this issue · 1 comments

Hello, I developed an API that accesses resources on my pod. Access to resources requires the user to authenticate. The user authenticates to a web application that consumes the API. The application uses the solid auth client. After authentication, the API is called and the resources are read from the pod and returned to the user. However, it only works if access is granted to the general public (acl:agentClass foaf:Agent). When I grant access to an individual agent (acl:agent https://jleles.solid.community/profile/card#me), I receive the following message: "401 - Unauthenticated".
How to solve this? Thanks to anyone who can help!

.acl

<#authorization>
    a acl:Authorization;
   acl:agent <https://jleles.solid.community/profile/card#me>;
    acl:accessTo <./file1.owl>;
    acl:default <./>;
    acl:mode acl:Read.

index.html

<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="UTF-8"/>
<title>Example Application</title>
</head>
<body>
     <p id="login">
        You are not logged in.
        <button>Log in</button>
     </p>
     <p id="logout">
        You are logged in as <span id="user"></span>.
        <button>Log out</button>
     </p>
    <script src="jquery.js"></script>
    <script src="solid-auth-client.bundle.js"></script>
    <script src="main.js"></script>
</body>
</html>

main.js

// Log the user in and out on click
const popupUri = 'popup.html';
$('#login  button').click(() => solid.auth.popupLogin({ popupUri }));
$('#logout button').click(() => solid.auth.logout());

// Update components to match the user's login status
solid.auth.trackSession(session => {
  const loggedIn = !!session;
  $('#login').toggle(!loggedIn);
  $('#logout').toggle(loggedIn);
  if (loggedIn) {
    $('#user').text(session.webId);
    solid.auth.fetch(URL_API).then(response => { response.json().then(data => { console.log(data) })});
   }
});

console.log view

{timestamp: "2020-03-03T15:49:17.864+0000", status: 500, error: "Internal Server Error", message: "401 - Unauthenticated", path: "..."}

Could you check your network logs show me the requests that are being made. Send me the curls by following this https://www.alexkras.com/copy-any-api-call-as-curl-request-with-chrome-developer-tools/

Be sure to not include your "authorization" header