
Hello all, this is my first time posting. I've got read a bunch of article already but I'm still stuck. The problem was about the OAuth redirect_uri.
Upon investigation, when my Appwrite server instance sends OAuth to providers, instead of sending "HTTPS", it sends "HTTP" as protocol for the redirect_url.
My Appwrite instance is running inside my self-hosted server and served via Cloudflare tunnel. I already tried applying host rewrite on my apache configuration but without any luck.
I've attached the screenshots for reference.
Thanks,

is your apache forwarding to HTTPS?

Hi Steven, yes, it is. This is my apache config currently:
ServerAdmin admin@coffeeandpaste.co
ServerName appwrite.coffeeandpaste.co
ProxyPreserveHost On
ProxyPass / http://localhost:5003/
ProxyPassReverse / http://localhost:5003/
RewriteEngine On
RewriteCond %{HTTP_HOST} !^appwrite\.coffeeandpaste\.co$ [NC]
RewriteRule ^(.*)$ https://appwrite.coffeeandpaste.co$1 [R=301,L]
</VirtualHost>```

Is the endpoint of when you're creating the GitHub OAuth 2 is HTTP or HTTPS?

it's HTTPS, I just copied the callback URL provided from the Appwrite console portal


I mean where you running the createOAuth2Session('github')
Your frontend

ah yes from my frontend

which is serving locally as of the moment

That's fine but as I saw through the code if this endpoint is not https then the redirects won't be https either So, Create another tunnel to the front end, and give it a try I think it will solve it

Thanks @Binyamin , I'll try to deploy the frontend to my server and see if it works

hi @Binyamin , it's still the same, here's the URL of the frontend: https://angular.coffeeandpaste.co/

It gives me an errro

The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application

You need to add or change so the https://angular.coffeeandpaste.co/ would be the webapp url

your ProxyPass is to http:// rather than https:// 🧐

Yes @Steven is correct (oc)
The AppWrite engine get the request
protocol as http

Hi Steven, I'm ProxyPassing the Appwrite instance served on the docker-compose inside my server, that's why it's http://localhost... Maybe I'll check if I can also forward the origin protocol and use it on the proxy. I'll update this post later. Thanks for all your help 😄

it would be best to proxy to HTTPS.
See: https://github.com/appwrite/appwrite/discussions/4056#discussioncomment-3784116

Hi Steven and byawitz, using "http" instead of "https" on the OAuth's callback URL works. Also adding success URL on createOAuth2Session() made things work as expected.
Thank you very much!

👍
Recommended threads
- Invalid redirect url
I keep getting invalid redirect url in Nextjs when i try to use google or github authentication
- I am getting a 401 unauthorized response...
I have a Next.js application that stores user PDFs. I'm able to save them normally, but when trying to access the files using getFileView, I get a 401 Unauthori...
- Error sending push message from dashboar...
I am trying to implement appwrite fully into my app and am switching over from firebase. I registered FCM as a Provider and tried to send a push message via the...
