I have figured out the issue. I have to make sure that the 'Authorized redirect URIs' list is empty in the Web Application OAuth 2 client.