I have problem using google OAuth2 with django: GSI_LOGGER]: The given origin is not allowed for the given client ID

I have an issue with @react-oauth/google npm package. When I using react app on port 3000 and backend django on port 8000 every thing work's, but after I build react app and using port 8000, I try to log in via google, I get that Erros:

Failed to load resource: the server responded with a status of 400 m=credential_button_library:45 [GSI_LOGGER]: The given origin is not allowed for the given client ID. I did double check on 'Authorised JavaScript origins' and 'Authorised redirect URIs' (image attached) but the giving origin are allowed, so whats can be the problem?

I read about similar problems here on the site and also tried CHAT GPT but nothing helped. This is my configurations:

CORS_ALLOWED_ORIGINS = [
    "http://localhost:8000",
    "http://localhost:3000",
    "http://127.0.0.1:3000",
    "http://127.0.0.1:8000"
]

class GoogleLogin(SocialLoginView):
    adapter_class = GoogleOAuth2Adapter
    callback_url = ['http://localhost:8000', 'http://localhost:3000', 'http://127.0.0.1:8000', 'http://localhost:8000/accounts/google/login/callback/']  # !
    client_class = OAuth2Client

enter image description here

enter image description here

Back to Top