Hi,
I'd greatly appreciate any help with the following.
Problem
I'm trying to enable "login with Google" on my website but I keep getting the above error.
Setup
- Odoo version: v18 Community Edition
- Server: Cloud server
- Web Protocol: HTTPS, using NGINX as a reverse proxy
- web.base.url: https://my-domain.com
- web.base.url.freeze: True
Nginx Configuration
server {
server_name my-domain.com www.my-domain.com subdomain.my-domain.com;
proxy_buffers 16 64k;
proxy_buffer_size 128k;
# Proxy requests to Odoo
location / {
proxy_pass http://127.0.0.1:8069;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Gzip configuration
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/my-domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/my-domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = subdomain.my-domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = www.my-domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = my-domain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name my-domain.com www.my-domain.com subdomain.my-domain.com;
return 404; # managed by Certbot
}
Odoo Config File
[options]
admin_passwd = ********
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /opt/odoo/odoo/addons,/opt/odoo/custom-addons
logfile = /var/log/odoo/odoo.log
proxy_mode = True
Oauth2 Error
Error 400: redirect_uri_mismatch
You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy.
If you're the app developer, register the redirect URI in the Google Cloud Console.
Request details: redirect_uri=http://www.my-domain/auth_oauth/signin flowName=GeneralOAuthFlow
Observations
It appears that, despite https working correctly on the site, NGINX is still passing http to Google.
Temporary Workaround
If I add the http version of my domain to my Google cloud project, it works correctly and allows test users to sign up and log in, but the drawback is that you can't publish the app with http URIs and I need external users to have this functionality.
Other Things I've Tried
I saw on one of the thousands of posts I've googled that what's being passed to Google is a Werkzeug variable that's picked up automatically from the sitemap. I don't know how accurate this information is but I acted on it and manually edited the sitemap, replacing http with https. This made no difference.
Conclusion
I have no idea why ths isn't working as expected and I don't understand why it's so difficult.
I'm already bald but if I had any hair, I would have pulled it all out by now!
Please help 🙏🏾