solid-file-python icon indicating copy to clipboard operation
solid-file-python copied to clipboard

Trying to login with a Solid Identity Provider causes an exception.

Open birchtree02 opened this issue 3 years ago • 0 comments

I have tried to follow the example in the getting started notebook in order to access private resources but it keeps throwing this error:

Traceback (most recent call last): File "C:\Users\edwar\Documents\coding\gerald\Solid_Server_Prototypes\python\pythonNotesApp\app.py", line 50, in <module> app = NotesApp() File "C:\Users\edwar\Documents\coding\gerald\Solid_Server_Prototypes\python\pythonNotesApp\app.py", line 12, in __init__ self.login() File "C:\Users\edwar\Documents\coding\gerald\Solid_Server_Prototypes\python\pythonNotesApp\app.py", line 28, in login self.auth.login(IDP, USERNAME, PASSWORD) File "C:\Users\edwar\Documents\coding\gerald\Solid_Server_Prototypes\python\solid-env\lib\site-packages\solid\auth.py", line 24, in login r.raise_for_status() File "C:\Users\edwar\Documents\coding\gerald\Solid_Server_Prototypes\python\solid-env\lib\site-packages\httpx\_models.py", line 1402, in raise_for_status raise HTTPStatusError(message, request=request, response=self) httpx.HTTPStatusError: 404 Client Error: Not Found for url: https://broker.pod.inrupt.com/login/password For more information check: https://httpstatuses.com/404

This is the code I am using: https://github.com/birchtree02/Solid_Prototypes/blob/main/python/pythonNotesApp/app.py

from solid.auth import Auth
from solid.solid_api import SolidAPI

import io
import json


class NotesApp():
    def __init__(self, folder_name="notes"):

        self.auth = Auth()
        self.login()
        self.folder_url = self.POD_ENDPOINT + folder_name + '/'

        if not self.api.item_exists(self.folder_url):
            self.api.create_folder(self.folder_url)
            if not self.api.item_exists(self.folder_url):
                raise Exception('Error initialising folder.')

    def login(self):
        configs = json.load(open('account.json'))
        self.POD_ENDPOINT = configs['SOLID_ENDPOINT']
        IDP = "https://broker.pod.inrupt.com"
        USERNAME = configs['SOLID_USERNAME']
        PASSWORD = configs['SOLID_PASSWORD']

        self.api = SolidAPI(self.auth)
        self.auth.login(IDP, USERNAME, PASSWORD)

        # self.api = SolidAPI()

    def editNote(self, note_name, content_to_add):
        note_url = self.folder_url + note_name + '.md'
        if not self.api.item_exists(note_url):
            self._createNote(note_url, content_to_add)
        else:
            pass

    def _createNote(self, note_url, content=""):
        self.api.put_file(note_url, io.BytesIO(content.encode('UTF-8')), 'text/markdown')

    def getNote(self, note_name):
        note_url = self.folder_url + note_name + '.md'
        resp = self.api.get(note_url)
        
        return resp.text


if __name__ == '__main__':
    app = NotesApp()

birchtree02 avatar Jul 25 '22 15:07 birchtree02