You can set the client metadata's redirect_uris to point to a custom page and run client.callback(urlQueryParams) in that page to complete the flow, although it should automatically handle this.
redirect_uris
client.callback(urlQueryParams)