javascriptreactjsgoogle-oauthgoogle-sso

Unable to use Google SSO on server react


I am trying to use Google SSO on a server but the popup for Google SSO doesn't display the google accounts to select for logging in. It works when I test it in my local and am able to login too.

I am using the package react-oauth/google

I have added server details in Credentials via Google Cloud Console. Following are URLs in configurations in Authorized JavaScript origins and Authorized redirect URIs:

http://localhost
http://localhost:9998 ## React app is running on this port
http://example.com:9998 ## Server url can be accessed using domain and port

I am getting 403 error when following url is called https://accounts.google.com/gsi/button:

enter image description here

Following is the error that is shown in cosole

[GSI_LOGGER]: The given origin is not allowed for the given client

Tried clearing cache and hard reload. It doesn't work either.

Does it have something to do with using ports along with domain name?

EDIT: I have also tried creating new credentials.. but that doesn't work either


Solution

  • I had the same issue at work. Does your website have ssl certificate? If not try adding ssl certicate (otherwise google sso won't work without it) and then change the urls in the Authorized JavaScript origins and Authorized redirect URIs with the https url. This should fix the issue. Let me know if it worked :)