Redirecturl issue when directly linking to external authentication

We have created an external authentication provider to Identity Server 3 following the information provided here which is working exactly as required.

We are now looking to automate the login process such that rather than visiting the community login page and clicking on the provider icon beneath the user name/password, users can instead click (for example) a button in the header that will take them direct to the external authentication provider and return them back to the community when logged in (bypassing the out of the box login page).

This all works fine with the exception that it always redirects them to the home page of the community rather than the page that they were viewing, which is obviously the desired result.

I have reviewed the widget ‘User – Login and Create’ which seems to handle this, but I’m struggling to see/understand how to achieve this functionality outside of using that widget and wondered if anyone knew or could advise on how to do so?  It looks as though when the user visits the community user login page, the redirect url is 'remembered' for when control is passed back to the community so that it can redirected but I’m struggling to implement this myself.

Any advice would be great!