The redirect URL must end with the same name as the document itself.
You can find the name in the breadcrumbs (top left corner in the screenshot).
The API Endpoint needs the full URL of the userinfo endpoint, since frappe/erpnext does not prepend the baseurl: frappe/oauth.py at a5d8c7aed8785e742057e1298b37c9bfa17a10a2 · frappe/frappe · GitHub (Frappe v13.5.1)
