TheFastOrg / Backend

Apache License 2.0
0 stars 0 forks source link

Fix Google Auth to return user token, name, and email in login response #14

Closed sweep-ai[bot] closed 1 year ago

sweep-ai[bot] commented 1 year ago

Description

This PR fixes the Google authentication in the backend to return the user token, name, and email as a response for login. Currently, the user is redirected to the profile page after login, but no token is returned in the response. This update is necessary to enable users to access their personal profiles in the mobile apps.

Summary of Changes

Please review and merge these changes to enable proper Google authentication and return the necessary user information in the login response.

Fixes #12.


To checkout this PR branch, run the following command in your terminal:

git checkout sweep/fix-google-auth

To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.

mhd-medfa commented 1 year ago

AssertionError: The field 'user' was declared on serializer BusinessSerializer, but has not been included in the 'fields' option.

mhd-medfa commented 1 year ago
for field in serializer.fields.values():

AttributeError: 'tuple' object has no attribute 'values'

mhd-medfa commented 1 year ago

if field.field_name in get_override(serializer, 'exclude_fields', []): AttributeError: 'str' object has no attribute 'field_name'

mhd-medfa commented 1 year ago

Still getting redirected to /accounts/profile/ :(

Page not found (404) Request Method: GET Request URL: http://localhost:8000/accounts/profile/

mhd-medfa commented 1 year ago

Nope! What I need is to return the same data saved in Django adminstration -> Home-> Social Accounts -> Social accounts -> account1

The data looks like this:

User: account1 Provider: Google Uid: 126458457777777999999 Extra data: {"iss": "https://accounts.google.com", "azp": "716529444916-gnqbiqic5hgjfsff5onjlt9idr5gvg2b.apps.googleusercontent.com", "aud": "716529444916-gnqbiqicj4gje8gf5onjlt9idr5gvg2b.apps.googleusercontent.com", "sub": "126458457777777999999", "email": "account1.email@gmail.com", "email_verified": true, "at_hash": "1L5vbSRKwe4C3JkUTdI9ap", "name": "Account One", "picture": "https://lh3.googleusercontent.com/a/AAcHTteaRtxDoddd1Rys2WZyreexZfeqKqWk_R75qf-U5pLS-Q=s96-c", "given_name": "Account", "family_name": "One", "locale": "en", "iat": 1691859542, "exp": 1691863142}

mhd-medfa commented 1 year ago

ImportError: cannot import name 'get_social_account' from 'allauth.socialaccount.models' (/workspaces/Backend/backend/venv/lib/python3.10/site-packages/allauth/socialaccount/models.py)