Python 401 only when streaming tried everything but no result


I am just testing the API with python framework tweepy. Everything works except streaming I triple checked my tokens and keys and they are the same. My machine time is also right.
Here is my code:

 class MyListener(tweepy.StreamListener):
      def on_data(self, data):
         with open("data.txt", 'w') as f:
              return True

def on_error(self, status):
    return True

auth = OAuthHandler(consumer_key=consumer_key,
auth.set_access_token(access_token, access_secret)

twitter_stream = tweepy.Stream(auth, MyListener())

The only thing I get is 401 which I know is unauthorized. I tried different ways of writing the code and etc but nothing works

P.S: I just saw that even tho my time is right for the time zone I am in but just posted tweets on my timeline are shown to be posted 1h ago can this be the cause? And how to fix?