Back

Google oauth2 redirect uri is wrong with http not https

  • 0
  • Accounts
  • Web
WildAnimal
16 Jul, 2023, 04:02

I have enabled google oauth2 provider in auth setting and configured it correctly. But when I click the button to start createOauth2Session with google I got the error message in google page as "redirect_uri_mismatch", and the detail information for developer is: require me to set up redirect_uri=http://api..., but I had configured the HTTPS redirect URI in google console for this oauth2 client ID. And My Appwrite console is also HTTPS and configured HTTPS endpoint in my app. Every step is correct, but I doubt that the createOauth2Session method used HTTP to initiate uri jumps. An important situation is that my Appwrite console uses nginx proxy to set up HTTPS. Is it related to this?

TL;DR
The user is facing an issue with the redirect URI in their Google OAuth2 configuration. They have configured the redirect URI with HTTPS, but they are getting a "redirect_uri_mismatch" error. They suspect that the issue might be related to their Nginx proxy setup. They are looking for suggestions on how to fix this. Solution: The user needs to ensure that they proxy pass to Appwrite using HTTPS instead of HTTP. They should update their Nginx proxy configuration to proxy pass to `https://127.0.0.1:<https port>`. This will ensure that the redirect URI matches the HTTPS configuration in Google Console
Drake
16 Jul, 2023, 04:03

You need to make sure to proxy pass to Appwrite using https

WildAnimal
16 Jul, 2023, 04:09

Thanks Steven. But how to impl this process. My nginx proxy configures like this:

TypeScript
    location / {
        proxy_pass http://127.0.0.1:2023;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header REMOTE-HOST $remote_addr;
        add_header X-Cache $upstream_cache_status;
        proxy_set_header X-Host $host:$server_port;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 30s;
        proxy_read_timeout 86400s;
        proxy_send_timeout 30s;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
Drake
16 Jul, 2023, 04:09

Proxy_pass https://127.0.0.1:<https port>

WildAnimal
16 Jul, 2023, 04:24

I had configured 2023 as 80, 2024 as 443 in docker-compose.yml file, but after I changed proxy pass to http://127.0.0.1:2024 , the console website become 404 page not found. 😦

TypeScript
services:
  traefik:
    image: traefik:2.7
    container_name: appwrite-traefik
    <<: *x-logging
    command:
      - --providers.file.directory=/storage/config
      - --providers.file.watch=true
      - --providers.docker=true
      - --providers.docker.exposedByDefault=false
      - --providers.docker.constraints=Label(`traefik.constraint-label-stack`,`appwrite`)
      - --entrypoints.appwrite_web.address=:80
      - --entrypoints.appwrite_websecure.address=:443
    restart: unless-stopped
    ports:
      - 2023:80
      - 2024:443
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - appwrite-config:/storage/config:ro
      - appwrite-certificates:/storage/certificates:ro
    depends_on:
      - appwrite
    networks:
      - gateway
      - appwrite
Drake
16 Jul, 2023, 04:59

It should be https

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more