I’m in the process of updating dependencies in my Django project. Specifically, I’m attempting to upgrade dj-rest-auth
to the latest version. I’ve been progressing incrementally without any issues until I reached version 5.0.0. However, now I’m encountering an AttributeError: 'GoogleProvider' object has no attribute 'app'
within the validate method of SocialLoginSerializer.
I’m uncertain about what might be causing this issue or what steps I should take to resolve it. Could someone please provide guidance on what might be going wrong and where I should focus my troubleshooting efforts?
My setup is pretty basic:
#settings.py:
SOCIALACCOUNT_PROVIDERS = {
"google": {
"SCOPE": { "profile", "email", },
"AUTH_PARAMS": { "access_type": "online", },
}
}
#views.py
class GoogleLogin(SaveOAuth2UserMixin, SocialLoginView):
adapter_class = GoogleOAuth2Adapter
@property
def callback_url(self):
state = self.request.data.get("state")
if state:
return f"https://my-custom-url.here"
return os.environ.get("GOOGLE_OAUTH_REDIRECT_URL")
def post(self, request, *args, **kwargs):
try:
return super().post(request, *args, **kwargs)
except OAuth2Error as e:
if "invalid_grant" in str(e):
return Response({"error": "my-message"}, status=status.HTTP_400_BAD_REQUEST)
raise
#mixins.py
class SaveOAuth2UserMixin:
client_class = OAuth2Client
def post(self, request, *args, **kwargs):
user = request.user
response = super().post(request, *args, **kwargs)
if response.status_code == status.HTTP_200_OK:
# updating user logic
return response
dep: django-allauth 0.54.0
Adam Kropiewnicki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.