Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TelegramAuth get_username get 'int' object is not subscriptable error #918

Closed
Fleapse opened this issue Jun 11, 2024 · 2 comments · Fixed by #921
Closed

TelegramAuth get_username get 'int' object is not subscriptable error #918

Fleapse opened this issue Jun 11, 2024 · 2 comments · Fixed by #921

Comments

@Fleapse
Copy link
Contributor

Fleapse commented Jun 11, 2024

Expected behaviour

the user should not receive errors

Actual behaviour

the user receive errors:
'int' object is not subscriptable
in social_core/pipeline/user.py in get_username at line 46

Any logs, error output, etc?

'int' object is not subscriptable
in social_core/pipeline/user.py in get_username at line 46

Any other comments?

if the user does not have a username in telegram, then he cannot log in

this happens because in social_core.backends.telegram.TelegramAuth
if the user does not have a username, it is replaced with an id with the int type

For myself I'm going to fix it like this:

class CustomTelegramAuth(TelegramAuth):
    def get_user_details(self, response):
        first_name = response.get("first_name", "")
        last_name = response.get("last_name", "")
        fullname = f"{first_name} {last_name}".strip()
        return {
            "username": response.get("username") or str(response[self.ID_KEY]),
            "first_name": first_name,
            "last_name": last_name,
            "fullname": fullname,
        }
old
"username": response.get("username") or response[self.ID_KEY],
new
"username": response.get("username") or str(response[self.ID_KEY]),

It seems that the same thing can be done here, so that others do not experience similar problems

@nijel
Copy link
Member

nijel commented Jun 12, 2024

Can you please create a pull request with the change?

Fleapse added a commit to Fleapse/social-core that referenced this issue Jun 21, 2024
Make username always a string to avoid errors in the user pipeline.
Fleapse pushed a commit to Fleapse/social-core that referenced this issue Jun 21, 2024
Make username always a string to avoid errors in the user pipeline.
@Fleapse
Copy link
Contributor Author

Fleapse commented Jun 21, 2024

#921
here it is

@nijel nijel linked a pull request Jun 24, 2024 that will close this issue
11 tasks
@nijel nijel closed this as completed in 3449faf Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants