Openid not found in authomatic.providers package

I have a Plone 6 installation with pas.plugins.oidc and pas.plugins.authomatic. They are installed and enabled in the Plone/Zope site.

This is the configuration of the providers for authomatic.
{
"github": {
"id": 1,
"display": {
"title": "Github",
"cssclasses": {
"button": "plone-btn plone-btn-default",
"icon": "glypicon glyphicon-github"
},
"as_form": false
},
"propertymap": {
"email": "email",
"link": "home_page",
"location": "location",
"name": "fullname"
},
"class_": "authomatic.providers.oauth2.GitHub",
"consumer_key": "Example, please get a key and secret. See",
"consumer_secret": "Sign in to GitHub · GitHub",
"access_headers": {
"User-Agent": "Plone (pas.plugins.authomatic)"
}
},
"cmc": {
"id": 2,
"display": {
"title": "CMC",
"cssclasses": {
"button": "plone-btn plone-btn-default",
"icon": "glypicon glyphicon-lock"
},
"as_form": false
},
"propertymap": {
"email": "email",
"link": "home_page",
"location": "location",
"name": "fullname"
},
"class_": "authomatic.providers.openid.OpenID",
"access_headers": {
"User-Agent": "Plone (pas.plugins.authomatic)"
}
}
}

I don't know why openid is not found. The providers module path is correct, the openid.py is there. Can someone help me figure out what is happening?

2024-04-05 11:21:22,626 ERROR [Zope.SiteErrorLog:36][waitress-2] ModuleNotFoundError: http://localhost:3000/@login
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 391, in publish_module
Module ZPublisher.WSGIPublisher, line 285, in publish
Module ZPublisher.mapply, line 98, in mapply
Module ZPublisher.WSGIPublisher, line 68, in call_object
Module plone.rest.service, line 21, in call
Module plone.restapi.services, line 19, in render
Module pas.plugins.authomatic.services.login, line 39, in reply
Module pas.plugins.authomatic.services.login, line 17, in list_plugins
Module pas.plugins.authomatic.utils, line 42, in authomatic_cfg
Module zope.dottedname.resolve, line 46, in resolve
Module authomatic.providers.openid, line 28, in
ModuleNotFoundError: No module named 'openid'

/home/ramiro/workspace/cmcuritiba/portal-volto/backend/lib/python3.10/site-packages/pas/plugins/authomatic/utils.py(40)authomatic_cfg()
-> for provider in cfg:
(Pdb) cfg
{'github': {'id': 1, 'display': {'title': 'Github', 'cssclasses': {'button': 'plone-btn plone-btn-default', 'icon': 'glypicon glyphicon-github'}, 'as_form': False}, 'propertymap': {'email': 'email', 'link': 'home_page', 'location': 'location', 'name': 'fullname'}, 'class_': 'authomatic.providers.oauth2.GitHub', 'consumer_key': 'Example, please get a key and secret. See', 'consumer_secret': 'Sign in to GitHub · GitHub', 'access_headers': {'User-Agent': 'Plone (pas.plugins.authomatic)'}}, 'cmc': {'id': 2, 'display': {'title': 'CMC', 'cssclasses': {'button': 'plone-btn plone-btn-default', 'icon': 'glypicon glyphicon-lock'}, 'as_form': False}, 'propertymap': {'email': 'email', 'link': 'home_page', 'location': 'location', 'name': 'fullname'}, 'class_': 'authomatic.providers.openid.OpenID', 'access_headers': {'User-Agent': 'Plone (pas.plugins.authomatic)'}}}
(Pdb) from authomatic import providers
(Pdb) providers.path
['/home/ramiro/workspace/cmcuritiba/portal-volto/backend/lib/python3.10/site-packages/authomatic/providers']
(Pdb) import os
(Pdb) os.listdir('/home/ramiro/workspace/cmcuritiba/portal-volto/backend/lib/python3.10/site-packages/authomatic/providers')
['openid.py', 'pycache', 'oauth2.py', 'oauth1.py', 'persona.py', 'init.py', 'gaeopenid.py']

1 Like

It says there's an error on line 28 of the authomatic.providers.openid module, not that it's having trouble finding authomatic.providers.openid. The actual error is that it can't find the top-level openid module.

The authomatic README says that python-openid is an optional dependency. Looking at authomatic/setup.py at master · authomatic/authomatic · GitHub, it appears you can do that by declaring a dependency on authomatic[OpenID]

1 Like

Got it, but can you tell where and how I declare this dependency? In requirements.txt on my project? Or in authomatic setup.py?

This is the line you mentioned right?

In your project (requirements.txt or setup.py)

It worked but not. There is another problem. The result of a map function is a map, and it has no len. The len is used to test the map result expecting to make sure it will be a tuple. But it throws an exception.

Module: lib/python3.10/site-packages/openid/init.py(52)

Captura de tela de 2024-04-08 14-34-44

Hummm, the repo is archived.

1 Like

I am using python-openid in requirements.txt

requirements.txt

-c constraints.txt

pas.plugins.oidc
pas.plugins.authomatic
# Needed by authomatic. https://community.plone.org/t/openid-not-found-in-authomatic-providers-package/19397/2?u=ramiroluz
python-openid
zope.testrunner
1 Like

On Python 3 you need python3-openid instead of python-openid.

If you would declare a dependency on authomatic[OpenID] like I suggested before, it would work. (Because the OpenID extra in the authomatic package is declared in a way that chooses the right package based on the Python version.)

1 Like

Nice, thanks, it worked.

Now I just need to learn how to setup the authomatic config in the backend.

Here is my test. But I am getting an error. Probably something missing in the following config.

{
    "cmc": {
        "id": 1,
        "display": {
            "title": "CMC",
            "cssclasses": {
                "button": "plone-btn plone-btn-default",
                "icon": "glypicon glyphicon-lock"
            },
            "as_form": false
        },
        "propertymap": {
            "email": "email",
            "link": "home_page",
            "location": "location",
            "name": "fullname"
        },
        "class_": "authomatic.providers.openid.OpenID",
        "redirect_uri": "http://localhost:8080/Plone/login_oidc/oidc",
        "access_headers": {
            "User-Agent": "Plone (pas.plugins.authomatic)"
        }
    }
}

Here is the error:

2024-04-09 11:14:24,374 ERROR   [140169299011632:351][waitress-1] authomatic: OpenID: Reported suppressed exception: OpenIDError('No identifier specified!')!
Traceback (most recent call last):
File "/home/ramiro/workspace/cmcuritiba/portal-volto/backend/lib/python3.10/site-packages/authomatic/providers/__init__.py", line 92, in wrap    func(provider, *args, **kwargs)                                                                                                              
File "/home/ramiro/workspace/cmcuritiba/portal-volto/backend/lib/python3.10/site-packages/authomatic/providers/openid.py", line 488, in login    raise OpenIDError('No identifier specified!')                                                                                              
authomatic.exceptions.OpenIDError: No identifier specified!                                                                                    
2024-04-09 11:14:24,375 INFO    [140169299011632:351][waitress-1] authomatic: OpenID: Procedure finished.

OpenID is not exactly openid-connect.

You can configure openid-connect with pas.plugins.oidc withouth pas.plugins.authomatic. Just install the addon and go to the pas plugin at acl_users/oidc/manage_propertiesForm to configure it.

1 Like

The backend login is working. The volto frontend is not being able to find /++api++/@login

I am accessing this url: http://localhost:3000/login?return_url=

The pas.plugins.oidc README says it is needed to use volto-authomatic.

It is installed in packages.json

"dependencies": {
   "@codesyntax/volto-social-sharing": "*",
   "@eeacms/volto-eea-kitkat": "*",
   "@kitconcept/volto-slider-block": "*",
   "@plone-collective/volto-authomatic": "*",
   "@plone/volto": "17.15.5"
},

My new requirements.txt

-c constraints.txt

pas.plugins.oidc
openid-connect
zope.testrunner

GET
http://localhost:3000/++api++/@login