[Fixed] google OAuth consent screen scheme error: Invalid domain: must not specify the scheme. (http:// or https://) – Oauth

by
Ali Hasan
django-authentication google-oauth next.js

Quick Fix: Do not specify the scheme (http:// or https://) in the Authorized domain field. This field does not accept localhost addresses. Instead, skip this field for test applications and add your domain address with the appropriate endpoint in the Authorized redirect URIs section in the Credentials menu.

The Solutions:

Solution 1: Invalid Domain Specification

The error arises because the Authorized domain field in the OAuth consent screen expects a valid domain name without a scheme (http:// or https://). Localhost addresses like "http://localhost:3000" are not accepted.

Resolution:

Skip the Authorized domain field when configuring OAuth2 for your test application. Specify the authorized redirect URIs in the Credentials menu instead. Use your domain address with the appropriate endpoint, for example:

https://yourdomain.com/auth/callback

Solution 2: Configure Hosts File

To resolve the issue, you can edit your /etc/hosts file to add an entry for your domain. For example:

127.0.0.1 test.cc

Replace "test.cc" with an arbitrary domain name of your choice. Save the file and run your development server locally using the specified domain instead of localhost:3000, e.g., test.cc:3000.

Once done, submit the specified domain as an authorized domain in your OAuth consent screen. This will allow you to use the specified domain for OAuth authentication without encountering the "Invalid domain" error.

Solution 3: Skip Authorized domains

The "Authorized domains" field in the OAuth consent screen does not accept localhost addresses. If you are setting up OAuth2 for a test application, skip this field. Instead, specify the Authorized redirect URIs in the Credentials menu. Enter your domain address and the appropriate endpoint to complete the setup.

Q&A

How to resolve ‘Invalid domain: must not specify the scheme error’?

The Authorized domain field does not accept localhost addresses. Skip this field for test applications and specify the Authorized redirect URIs in the Credentials menu.

How to configure OAuth2 for test applications?

Skip the Authorized domain field for test applications and specify the Authorized redirect URIs in the Credentials menu.

Video Explanation:

The following video, titled "How the fix redirect_uri_mismatch error. #googledevelopers ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

In this video, you will learn how to fix the redirect_uri_mismatch error when using Google OAuth. This is a common error that can occur when ...