OAuth 2: redirecting a user to the original URL after login

In the OAuth 2 server I developed for the Humanitarian ID v2 project, some client applications asked me if it was possible to redirect the user after login to their originating URL. It turns out that this the responsibility of the client application. Here is how to do it.

For example, if the user is browsing your site on https://somesite.com/page1 and clicks on the “Login” button, the user is browsing away from your site, following the OAuth 2 procedure to login on a remote server. When the login procedure is successful, the…