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

TypeError: unsupported operand type(s) for +: 'int' and 'bytes' #200

Open
NightDev19 opened this issue Jan 24, 2023 · 2 comments
Open

TypeError: unsupported operand type(s) for +: 'int' and 'bytes' #200

NightDev19 opened this issue Jan 24, 2023 · 2 comments

Comments

@NightDev19
Copy link

i think that return s.dumps({'user_id': self.id}).decode('utf-8') cant rea for newer version of python

@SamBlackDev
Copy link

I got it working by using the 'URLSafeTimedSerializer' module instead.

Steps to receive same results

  1. Remove 'expires_sec' arg from 'get_reset_token' function.
  2. remove the decode to utf-8 section.
  3. Add the 'max_age' arg to the 's.loads' command.

Before

from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
def get_reset_token(self, expires_sec=1800):
        s = Serializer(app.config['SECRET_KEY'], expires_sec)
        return s.dumps({'user_id': self.id}).decode('utf-8')
@staticmethod
 def verify_reset_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token)['user_id']
        except:
            return None
        return User.query.get(user_id)

After (Updated)

from itsdangerous import URLSafeTimedSerializer as Serializer
def get_reset_token(self):
        s = Serializer(app.config['SECRET_KEY'])
        return s.dumps({'user_id': self.id})
@staticmethod
 def verify_reset_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            user_id = s.loads(token, max_age=1800)['user_id']
        except:
            return None
        return User.query.get(user_id)

@Masayaelvin
Copy link

go to you gmail account settings > security > 2 step verification>app >create new

you can name it whatever you want google will generate a password for your app you won't need to use your actual google password

copy the password and paste it in app[MAIL_PASS] and you'll be good to go.
If your 2 step verification is off you'll have to turn it on hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants