python-ring-doorbell icon indicating copy to clipboard operation
python-ring-doorbell copied to clipboard

Auth working on mac but not on Ubuntu

Open MnLgt opened this issue 2 years ago • 5 comments

When I run this on my local machine (macbook pro m1) it works, I've also tried it on colab and it works. However, I tried using it on a digitalocean droplet VM running Ubuntu and keep getting the following error:

hit exception (missing_token) Missing access token parameter.

The logs all seem to show the same requests being created but the Ubuntu request hits a 406 error

406 Client Error: Not Acceptable for url: https://api.ring.com/clients_api/session?api_version=9

The relevant functions from my script are:

def token_updated(token):
    cache_file().write_text(json.dumps(token))

def otp_callback():
    auth_code = input("2FA code: ")
    return auth_code

def login_to_ring(ua, username, password):
    if cache_file().is_file():
        auth = Auth(ua, json.loads(cache_file().read_text()), token_updated) <--- it fails here
    else:
        auth = Auth(ua, None, token_updated)
        try:
            auth.fetch_token(username, password)
        except MissingTokenError:
            auth.fetch_token(username, password, otp_callback())

    global ring
    ring = Ring(auth)
    ring.update_data()
    return ring

I have the exact same version of python3.9 running on my local machine and droplet. The ports are all open on my VM and I've made other get/post requests without an issue. I've tried using the ring_token.cache file generated on my local machine on the VM, no bueno. I've tried to get a new token file generated on the VM, but additional lack of bueno.

I'm guessing that it's not fetching a new token due to some kind of text encoding issue but I can't be sure. I've turned on logging for the requests and there doesn't seem to be a difference between the local, colab, or VM logs.

Please let me know if anyone has any ideas or if there's any additional information I should be providing.

MnLgt avatar Sep 12 '22 22:09 MnLgt

@MnLgt I'm having the same problem (albeit on VULTR, not digital ocean) - just starting to troubleshoot it further. Did you ever solve this?

I've found that 2FA texts are not triggered from any VULTR instance that I've spun up - although they are successfully triggered from ubuntu locally, from windows locally, locally with VPN on....

All firewalls disabled and DNS working on the VULTR instances.

andrew-rinato avatar Nov 27 '23 12:11 andrew-rinato

Can't get it to generate a token from AWS EC2, either

andrew-rinato avatar Nov 27 '23 18:11 andrew-rinato

@andrew-rinato No i never did. I gave up on the project but at the time I was working on it ChatGPT was still on GPT3. GPT4 is much better at these types of things. I find that it doesn't work as well when you tell it the problem you're having and ask it to fix it. Instead, I would suggest giving it your request script and instruct it to refactor the script for calls from an ubuntu cloud server (or whatever os your machine is running on). Kind of a long shot but it might update the parts that are causing the issue. Hope this helps.

MnLgt avatar Nov 27 '23 21:11 MnLgt

@MnLgt thanks for getting back to me.

It started working from the ubuntu 22.04 on aws today, but not on vultr. I wonder if there isnt some gating on their side that I can't quite decode. I've seen similar reports regarding the 406 from both ring repos (typescript and python).

If I ever track it down to something we have control over I'll post it back here.

andrew-rinato avatar Nov 28 '23 11:11 andrew-rinato

Sorry if my last post was kind of confusing, i wrote it in a hurry. The reason I resorted to ChatGPT is because it was fruitless trying to search for a solution to a problem i couldn't explain/diagnose. Good luck.

MnLgt avatar Nov 28 '23 22:11 MnLgt

There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs. Please make sure to update to the latest ring_doorbell version and check if that solves the issue. Thank you for your contributions.

github-actions[bot] avatar Apr 18 '24 18:04 github-actions[bot]