Social Authentication with django-allauth

Hi. I’m trying to implement social authentication with using django-allauth. Every works fine when testing until the last part where I have chosen my google account and press continue and then this error:

JSONDecodeError at /api/v1/auth/google/callback/
Expecting value: line 1 column 1 (char 0)
Expecting value: line 1 column 1 (char 0)
Exception Location: C:\Users\Boostan1999\.virtualenvs\SocialAuth-C1HobtWO\Lib\site-packages\requests\models.py, line 980, in json
Raised during: accounts.views.GoogleLoginCallback
undefined —:
Python Executable: C:\Users\Boostan1999\.virtualenvs\SocialAuth-C1HobtWO\Scripts\python.exe
undefined —:
Python Version: 3.13.5
undefined —:
Python Path:
undefined —:
['F:\\SocialAuth',
 'C:\\Users\\Boostan1999\\.virtualenvs\\SocialAuth-C1HobtWO\\Scripts\\python313.zip',
 'C:\\Python313\\DLLs',
 'C:\\Python313\\Lib',
 'C:\\Python313',
 'C:\\Users\\Boostan1999\\.virtualenvs\\SocialAuth-C1HobtWO',
 'C:\\Users\\Boostan1999\\.virtualenvs\\SocialAuth-C1HobtWO\\Lib\\site-packages']

I read somewhere that this is due to incompatibility issue between dj-rest-auth and django-allauth versions so I downgraded to dj-rest-auth==7.0.0 and django-allauth==0.61.1 and also wrote custom client.
accounts/views.py:
```
class CustomGoogleOAuth2Client(OAuth2Client):

def \__init_\_(

    self,

    request,

    consumer_key,

    consumer_secret,

    access_token_method,

    access_token_url,

    callback_url,

    \_scope,  # This is fix for incompatibility between django-allauth==65.3.1 and dj-rest-auth==7.0.1

    scope_delimiter=" ",

    headers=None,

    basic_auth=False,

):

    super().\__init_\_(

        request,

        consumer_key,

        consumer_secret,

        access_token_method,

        access_token_url,

        callback_url,

        scope_delimiter,

        headers,

        basic_auth,

    )

class GoogleLogin(SocialLoginView):

adapter_class = GoogleOAuth2Adapter

callback_url = settings.GOOGLE_OAUTH_CALLBACK_URL

client_class = CustomGoogleOAuth2Client

class GoogleLoginCallback(APIView):

def get(self, request, \*args, \*\*kwargs):

    code = request.GET.get("code")

    if code is None:

        return Response(status=status.HTTP_400_BAD_REQUEST)

    token_endpoint_url = urljoin("http://localhost:8000", reverse("google_login"))

    response = requests.post(url=token_endpoint_url, data={"code": code})

    return Response(response.json(), status=status.HTTP_200_OK)

class LoginPage(View):

def get(self, request, \*args, \*\*kwargs):

    return render(

        request,

        'pages/login.html', {

            'google_callback_uri': settings.GOOGLE_OAUTH_CALLBACK_URL,

            "google_client_id": settings.GOOGLE_OAUTH_CLIENT_ID, 

        },

    )

config/urls.py:

urlpatterns = [
path("admin/", admin.site.urls),

path("login/", LoginPage.as_view(), name="login"),

path("api/v1/auth/", include("dj_rest_auth.urls")),

re_path(r"^api/v1/auth/accounts/", include("allauth.urls")),

path("api/v1/auth/registration/", include("dj_rest_auth.registration.urls")),

path("api/v1/auth/google/", GoogleLogin.as_view(), name="google_login"),

path(

    "api/v1/auth/google/callback/",

    GoogleLoginCallback.as_view(),

    name="google_login_callback",

),

]
```

any help is appreciated.

[Moderator’s note: When posting code here, please remember to enclose the code between lines of three backtick - ` characters.]