DRF SocialLoginView callback_url is not redirecting on AppleLogin

399 Views Asked by At

Trying to implement apple login in django rest allauth. /user/apple/ creates the account. And callback_url is set to /user/apple/login/callback/

When I hit callback_url from POSTMAN, it redirects. But the endpoint /user/apple/ does not call the callback_url.

urls.py

urlpatterns = [
...
    path("user/apple/", AppleLogin.as_view(), name="apple-login"),
    path('user/apple/login/callback/', apple_callback, name="apple_callback"),
...
]

views.py

from rest_auth.registration.views import SocialLoginView
...
class AppleLogin(SocialLoginView):
    adapter_class = AppleOAuth2Adapter
    # also tried this way
    # callback_url = '<doamin>/user/apple/login/callback/'
    client_class = AppleOAuth2Client
    serializer_class = CustomAppleSocialLoginSerializer

    @property
    def callback_url(self):
        return self.request.build_absolute_uri(reverse('apple_callback'))


def apple_callback(request):
    return redirect('<domain>/editprofile')
...

serializers.py is working with CustomAppleSocialLoginSerializer and the account is also being created in the database.

What can be going wrong?

1

There are 1 best solutions below

0
On

The redirectlink is without the / at the end. So # callback_url = '<doamin>/user/apple/login/callback'