Using a custom social login provider (Authentik)

Hi there,

I tried to integrate my custom social login provider (authentik).

According to the slightly limited documentation the redirect URL should be:

/api/method/frappe.integrations.oauth2_logins.custom/authentik

But then I get the follwing error message:

Traceback (most recent call last):
File “apps/frappe/frappe/app.py”, line 69, in application
response = frappe.api.handle()
File “apps/frappe/frappe/api.py”, line 54, in handle
return frappe.handler.handle()
File “apps/frappe/frappe/handler.py”, line 45, in handle
data = execute_cmd(cmd)
File “apps/frappe/frappe/handler.py”, line 83, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “apps/frappe/frappe/init.py”, line 1599, in call
return fn(*args, **newargs)
TypeError: custom() missing 2 required positional arguments: ‘code’ and ‘state’

Any ideas how to solve this?

Thanks lot!

Meanwhile I figured out how to set up Authentik as custom social login provider (works really nice).

This is the configuration needed in ERPNext / Frappe:

Client ID: From Authentik Provider
Client secret: From Authentik Provider
Base URL {URL of your Authentik instance}
Authorize URL /application/o/authorize/
Redirect URL /api/method/frappe.integrations.oauth2_logins.custom/authentik (if you name the social login “authentik”)
Access Token URL /application/o/token/
API Endpoint https://{URL of your Authentik instance}/application/o/userinfo

In Authentik you have to do:

Create a new OAuth2 / OpenID provider
Client type: confidential
Client ID / secret should get auto generated → put in ERPNext (see above)
Redirect URI: https://{URL of your ERPNext Site}/api/method/frappe.integrations.oauth2_logins.custom/authentik (if you name the social login “authentik”)
Signing Key: Create a new self-signed key

Create a new app in Authentik and assign the provider you created
Set everything up to your liking (Name, description, icon, etc.)
Launch URL: Copy the Link from your ERPNext Site which should say: Login with authentik (or every other name you picked)

Hope that helps other user that want to use Authentik as SSO / Social Login provider