mdesilva / AmazonFlexUnlimited

Automate the process of grabbing job blocks from Amazon Flex
174 stars 101 forks source link

error code 307 workaround #101

Open travislazzaro opened 1 year ago

travislazzaro commented 1 year ago

@kyleanderson84 posted some code for a workaround, but i'm trying to figure out why i get prompted even if its not a 307 error code? here is the code:

elif request.statuscode == 307: #manualy complete amazon captcha if self.twilioClient is not None: self.twilioClient.messages.create(to=self.twilioToNumber, from=self.twilioFromNumber, body="Manually complete amazon flex captcha and return to bot to unpause") while(1): answer = input("Complete Captcha?:(Y/N").lower() if answer == "y": break

it prompts "Complete captcha Y/N" even if it successfully accepts an offer. trying to figure out how to have it only prompt and pause when its a 307 error code.

travislazzaro commented 1 year ago

does this code look correct?

if request.status_code == 200: self._acceptedOffers.append(offer) if self.twilioClient is not None: self.twilioClient.messages.create( to=self.twilioToNumber, from=self.twilioFromNumber, body=offer.toString()) Log.info(f"Successfully accepted an offer.") elif request.statuscode == 307: if self.twilioClient is not None: self.twilioClient.messages.create( to=self.twilioToNumber, from=self.twilioFromNumber, body="Manually complete amazon flex captcha and return to bot to unpause") while True: answer = input("Complete Captcha? (Y/N)").lower() if answer == "y": break elif answer == "n": Log.error("Captcha was not completed. Unable to accept an offer.") break else: print("Invalid input. Please enter Y or N.") else: Log.error(f"Unable to accept an offer. Request returned status code {request.status_code}")

asadbek064 commented 1 year ago

@kyleanderson84 posted some code for a workaround, but i'm trying to figure out why i get prompted even if its not a 307 error code? here is the code:

elif request.status_code == 307: #manualy complete amazon captcha

if self.twilioClient is not None:

self.twilioClient.messages.create(to=self.twilioToNumber,

from_=self.twilioFromNumber,

body="Manually complete amazon flex captcha and return to bot to unpause")

while(1):

answer = input("Complete Captcha?:(Y/N").lower()

if answer == "y":

break

it prompts "Complete captcha Y/N" even if it successfully accepts an offer. trying to figure out how to have it only prompt and pause when its a 307 error code.

Thanks for the info I think I can implement a feature as you described but we can halt the thread by event.wait(). After user completes the captch he cans reply to twillio message YES on receiving of this response we can continue or cancel the script

travislazzaro commented 1 year ago

@kyleanderson84 posted some code for a workaround, but i'm trying to figure out why i get prompted even if its not a 307 error code? here is the code:

elif request.status_code == 307: #manualy complete amazon captcha

if self.twilioClient is not None:

self.twilioClient.messages.create(to=self.twilioToNumber,

from_=self.twilioFromNumber,

body="Manually complete amazon flex captcha and return to bot to unpause")

while(1):

answer = input("Complete Captcha?:(Y/N").lower()

if answer == "y":

break

it prompts "Complete captcha Y/N" even if it successfully accepts an offer. trying to figure out how to have it only prompt and pause when its a 307 error code.

Thanks for the info I think I can implement a feature as you described but we can halt the thread by event.wait(). After user completes the captch he cans reply to twillio message YES on receiving of this response we can continue or cancel the script

Can you post the code here?

rgribeiro2009 commented 1 year ago
  if request.status_code == 200:
      self.__acceptedOffers.append(offer)
      if self.twilioClient is not None:
        self.twilioClient.messages.create(
          to=self.twilioToNumber,
          from_=self.twilioFromNumber,
          body=offer.toString())
        Log.info(f"Successfully accepted an offer.")
      elif request.status_code == 307: #manualy complete amazon captcha
        if self.twilioClient is not None:
          self.twilioClient.messages.create(
            to=self.twilioToNumber, 
            from_=self.twilioFromNumber,
            body=offer.tostring())
          while(1):
            answer = input("Complete Captcha?:(Y/N").lower()
            if answer == "y":
              break
            else:
              Log.error(f"Unable to accept an offer. Request returned status code {request.status_code}")

even with the code above still appears this message: ERROR: Unable to accept an offer. Request returned status code 307

can anyone help me?

asadbek064 commented 1 year ago

Even with re authentication 307 error still stands. I will try to capture all logs from bot and my device and post it here. I feel like we need to capture auth token from the app and use the same token on bot. Is there any docs or information on how the captacha works I know it's third party service they are using.

kyleanderson84 commented 1 year ago
  if request.status_code == 200:
      self.__acceptedOffers.append(offer)
      if self.twilioClient is not None:
        self.twilioClient.messages.create(
          to=self.twilioToNumber,
          from_=self.twilioFromNumber,
          body=offer.toString())
        Log.info(f"Successfully accepted an offer.")
      elif request.status_code == 307: #manualy complete amazon captcha
        if self.twilioClient is not None:
          self.twilioClient.messages.create(
            to=self.twilioToNumber, 
            from_=self.twilioFromNumber,
            body=offer.tostring())
          while(1):
            answer = input("Complete Captcha?:(Y/N").lower()
            if answer == "y":
              break
            else:
              Log.error(f"Unable to accept an offer. Request returned status code {request.status_code}")

even with the code above still appears this message: ERROR: Unable to accept an offer. Request returned status code 307

can anyone help me?

The elif shouldn't be indented and should line up with the first if statement