diff --git a/Dockerfile b/Dockerfile
index 5164b39bf3070cdc2d36e0e0b4036392eef4404a..e35f97d6be7196eb3f57d7dfb350ef218fcf935b 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,12 +2,19 @@ FROM python:3.11
 
 WORKDIR /django
 
-COPY manage.py requirements.txt /django/
+COPY manage.py requirements.txt django-allauth.patch /django/
 COPY project/ /django/project
 
 RUN \
     set -ex && \
-    pip install --no-cache-dir -r requirements.txt
+    pip install --no-cache-dir -r requirements.txt && \
+    pip uninstall -y django-allauth[socialaccount] && \
+    git clone https://codeberg.org/allauth/django-allauth.git --depth 1 --branch 65.6.0 && \
+    cd django-allauth && \
+    git apply ../django-allauth.patch && \
+    cd .. && \
+    pip install -e django-allauth[socialaccount]
+    
 
 # Don't care about the relational database at the moment.
 RUN \
diff --git a/django-allauth.patch b/django-allauth.patch
new file mode 100644
index 0000000000000000000000000000000000000000..4586ebd4b644f3df324919705d9d78994f1c7e50
--- /dev/null
+++ b/django-allauth.patch
@@ -0,0 +1,22 @@
+diff --git a/allauth/socialaccount/providers/oauth2/client.py b/allauth/socialaccount/providers/oauth2/client.py
+index c0098df..81f610f 100644
+--- a/allauth/socialaccount/providers/oauth2/client.py
++++ b/allauth/socialaccount/providers/oauth2/client.py
+@@ -1,3 +1,6 @@
++import os
++import urllib
++
+ import requests
+ from urllib.parse import parse_qsl
+ 
+@@ -28,8 +31,8 @@ class OAuth2Client:
+         self.request = request
+         self.access_token_method = access_token_method
+         self.access_token_url = access_token_url
+-        self.callback_url = callback_url
+-        self.consumer_key = consumer_key
++        self.callback_url = os.environ.get("IAM4NFDI_REDIRECT_URI")
++        self.consumer_key = urllib.parse.quote_plus(consumer_key)
+         self.consumer_secret = consumer_secret
+         self.scope_delimiter = scope_delimiter
+         self.state = None