Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test login command #46

Open
evanp opened this issue Nov 12, 2023 · 5 comments
Open

test login command #46

evanp opened this issue Nov 12, 2023 · 5 comments

Comments

@evanp
Copy link
Owner

evanp commented Nov 12, 2023

No description provided.

@evanp evanp added this to ap 1.0 Nov 12, 2023
@evanp evanp converted this from a draft issue Nov 12, 2023
@naturzukunft
Copy link

Hi @evanp ,
i just tested the login. The actor is :

{
    "id": "https://dev.rdf-pub.org/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d",
    "type": "Person",
    "inboxSparql": "https://dev.rdf-pub.org/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/inbox/sparql",
    "outboxSparql": "https://dev.rdf-pub.org/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/outbox/sparql",
    "identifier": "1813bdc1-152c-4c27-92a6-6cdfe401ef3d",
    "version": {
        "type": "xsd:integer",
        "@value": "1"
    },
    "inbox": "https://dev.rdf-pub.org/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/inbox",
    "endpoints": "https://dev.rdf-pub.org/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/objects/fd93e263-05ae-4d12-acfa-2fd92bf89e07",
    "outbox": "https://dev.rdf-pub.org/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/outbox",
    "preferredUsername": "max",
    "@context": [
        "https://schema.org/docs/jsonldcontext.json",
        "https://www.w3.org/ns/activitystreams",
        "https://rdf-pub.org/schema/rdf-pub-context.json"
    ]
}```

and the endpoints is:

{
    "id": "https://dev.rdf-pub.org/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/objects/fd93e263-05ae-4d12-acfa-2fd92bf89e07",
    "identifier": "0ac95648-2892-43f5-8952-d1e7756c6b8b",
    "version": {
        "type": "xsd:integer",
        "@value": "1"
    },
    "oauthAuthorizationEndpoint": "https://login.m4h.network/auth/realms/LOA/protocol/openid-connect/auth",
    "oauthTokenEndpoint": "https://login.m4h.network/auth/realms/LOA/protocol/openid-connect/token",
    "@context": [
        "https://schema.org/docs/jsonldcontext.json",
        "https://www.w3.org/ns/activitystreams",
        "https://rdf-pub.org/schema/rdf-pub-context.json"
    ]
}

Result:

ap$ ap login max@dev.rdf-pub.org
Traceback (most recent call last):
  File "/usr/local/bin/ap", line 33, in <module>
    sys.exit(load_entry_point('ap==0.1.0.dev0', 'console_scripts', 'ap')())
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/main.py", line 299, in main
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/main.py", line 294, in run_command
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/commands/login.py", line 82, in run
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/commands/login.py", line 55, in oauth_endpoints
AttributeError: 'str' object has no attribute 'get'

@evanp
Copy link
Owner Author

evanp commented Dec 22, 2023

I don't think "endpoints" can be an URL. But I should add a check for this.

@naturzukunft
Copy link

endpoints
A json object which maps additional (typically server/domain-wide) endpoints which may be useful either for this actor or someone referencing this actor. This mapping may be nested inside the actor document as the value or may be a link to a JSON-LD document with these properties.

For me A json object is a wrong therm here. It should be A JSON-LD object.

@naturzukunft
Copy link

See also this discussion regarding blank nodes.

@naturzukunft
Copy link

it looks as if the login worked but the token was not saved:

$ ap login @max@dev.rdf-pub.org
Opening in existing browser session.
127.0.0.1 - - [15/Jan/2024 11:11:00] "GET /callback?state=OvpgGi2zRLcSGOm43Hs6jW4TKVPX0E&session_state=0257c22e-f026-4fc0-9493-45210f7846a1&code=da44e390-3e25-4244-a749-679806a61a64.0257c22e-f026-4fc0-9493-45210f7846a1.d58672bf-b58a-45ea-b177-852ef690cee7 HTTP/1.1" 200 -
----------------------------------------
Exception occurred during processing of request from ('127.0.0.1', 38414)
Traceback (most recent call last):
  File "/usr/lib/python3.10/socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python3.10/socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python3.10/socketserver.py", line 747, in __init__
    self.handle()
  File "/usr/lib/python3.10/http/server.py", line 433, in handle
    self.handle_one_request()
  File "/usr/lib/python3.10/http/server.py", line 421, in handle_one_request
    method()
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/commands/login.py", line 30, in do_GET
    LoginRedirectHandler.command.on_callback(
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/commands/login.py", line 123, in on_callback
    token = self.oauth.fetch_token(
  File "/usr/local/lib/python3.10/dist-packages/requests_oauthlib-1.3.1-py3.10.egg/requests_oauthlib/oauth2_session.py", line 366, in fetch_token
    self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 448, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 441, in parse_token_response
    validate_token_parameters(params)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 471, in validate_token_parameters
    raise w
Warning: Scope has changed from "write read" to "write email profile read".
----------------------------------------
$ ap whoami
Traceback (most recent call last):
  File "/usr/local/bin/ap", line 33, in <module>
    sys.exit(load_entry_point('ap==0.1.0.dev0', 'console_scripts', 'ap')())
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/main.py", line 299, in main
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/main.py", line 294, in run_command
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/commands/whoami.py", line 9, in run
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/commands/command.py", line 40, in logged_in_actor
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/commands/command.py", line 22, in logged_in_actor_id
  File "/usr/local/lib/python3.10/dist-packages/ap-0.1.0.dev0-py3.10.egg/ap/commands/command.py", line 34, in token_file_data
FileNotFoundError: [Errno 2] No such file or directory: '/home/xxxxxxxxxxxxx/.ap/token.json'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants