Although there is a fix for this as per https://tracker.moodle.org/browse/MDL-59473, the redirection loop still occurs.
The workaround for this would be to add "response_mode=query" for both "Additional parameters included in a login request." and "Additional parameters included in a login request for offline access." options