original_docstring: 
          Look implementation notes
          This API implemented JWT. Token's payload contain:
          'uid' (user id),
          'exp' (expiration date of the token),
          'iat' (the time the token is generated)
          
docstring: Look implementation notes
  This API implemented JWT.
docstring_tokens: Look implementation notes This API implemented JWT .
code: def post(self):
          """
          Look implementation notes
          This API implemented JWT. Token's payload contain:
          'uid' (user id),
          'exp' (expiration date of the token),
          'iat' (the time the token is generated)
          """
          try:
              user = auth_service.find_user(username=api.payload['username'])
  
              if check_password_hash(user.password_hash, api.payload['password']):
                  token_pair = auth_service.generate_token(user_id=user.id, secret=current_app.config['SECRET_KEY'])
  
                  user_agent_string = request.user_agent.string.encode('utf-8')
                  user_agent_hash = hashlib.md5(user_agent_string).hexdigest()
  
                  refresh_token = auth_service.store_refresh_token(
                      user=user,
                      user_agent_hash=user_agent_hash,
                      refresh_token=token_pair.refresh_token
                  )
  
                  return {'access_token': token_pair.access_token, 'refresh_token': refresh_token.refresh_token}, 200
  
              else:
                  auth_v1_ns.abort(401, 'Incorrect username or password')
  
          except auth_service.UserNotFoundException:
              auth_v1_ns.abort(401, 'Incorrect username or password')
          except auth_service.AuthenticationException:
              auth_v1_ns.abort(500, 'Unexpected authentication error')
code_tokens: def post ( self ) : try : user = auth_service . find_user ( username = api . payload [ 'username' ] ) if check_password_hash ( user . password_hash , api . payload [ 'password' ] ) : token_pair = auth_service . generate_token ( user_id = user . id , secret = current_app . config [ 'SECRET_KEY' ] ) user_agent_string = request . user_agent . string . encode ( 'utf-8' ) user_agent_hash = hashlib . md5 ( user_agent_string ) . hexdigest ( ) refresh_token = auth_service . store_refresh_token ( user = user , user_agent_hash = user_agent_hash , refresh_token = token_pair . refresh_token ) return { 'access_token' : token_pair . access_token , 'refresh_token' : refresh_token . refresh_token } , 200 else : auth_v1_ns . abort ( 401 , 'Incorrect username or password' ) except auth_service . UserNotFoundException : auth_v1_ns . abort ( 401 , 'Incorrect username or password' ) except auth_service . AuthenticationException : auth_v1_ns . abort ( 500 , 'Unexpected authentication error' )
short_docstring: Look implementation notes
  This API implemented JWT.
short_docstring_tokens: Look implementation notes This API implemented JWT .
comment: """
          Look implementation notes
          This API implemented JWT. Token's payload contain:
          'uid' (user id),
          'exp' (expiration date of the token),
          'iat' (the time the token is generated)
          """