When using a custom login route for IdP-initiated SSO, you’ll need to specify a query string to specify the login route and the query parameters. Note that you don’t need to encode the URL; just provide it raw.
redirect_uri=https://yourdomain.com/customlogin?connection=123