Closed kskenyon closed 2 years ago
I got the authentication to complete on raspbian Buster, however, the gmail.credentials file that it created appears to be corrupt. I get a 401 error running any of the example code. I repeated it to be sure. Can you verify that this code is still working?
python3 arlo-snapshot.py 401 Client Error: for url: https://my.arlo.com/hmsweb/users/devices
{ "success": false, "data": { "error": "2401", "message": "Access token is empty or unauthorized request", "reason": "Empty token" } }
chromium-browser https://my.arlo.com/hmsweb/users/devices Opening in existing browser session. python3 arlo-snapshot.py 401 Client Error: for url: https://my.arlo.com/hmsweb/users/devices
This happened to me too w/ Python 3.9 in Ubuntu 20.04.
Looks like _RedirectWSGIApp.__call__
isn't being called for some reason, so the URL isn't stored.
I was able to work around by adding a import pdb; pdb.set_trace()
debugger on the line before authorization_response = wsgi_app.last_request_uri.replace("http", "https")
of flow.py
, then manually assigning the URI from my browser with
wsgi_app.last_request_uri = 'http://localhost:7788/?state=0X...'
continue
Got my state OK. Not sure where I'm supposed to insert the manual wsgi_app.last_request_uri = 'http://localhost:7788/?state=0X...' continue
Does it replace the lines after the pbd call?
Type those lines into the debugger when you hit the pdb.set_trace()
call
Guess I'm out of my league. How do I get into the debugger? I can only tweak python3, I don't write code. Are you using an IDE?
I manually edited flow.py with nano in the terminal then ran gmail_oauth.py which outputted the state=
But it doesn't seem to allow me to enter the wsgi_app.last_request_uri = 'http://localhost:7788/?state=0x... line there.
Does your 0x indicate the state is supposed to be in hex? Mine isn't in hex.
Pardon my ignorance?
K
Traceback (most recent call last):
File "./gmail_oauth.py", line 24, in
The browser session closes too soon?
Make sure you're adding the debugger (import pdb; pdb.set_trace()
) to the flow.py at /usr/local/lib/python3.7/dist-packages/google_auth_oauthlib-0.4.6-py3.7.egg/google_auth_oauthlib/flow.py
, since that's the one being executed.
When you run python3 gmail_oauth.py
, it should pause when the program execution hits the pdb.set_trace()
line, and open an interactive prompt. That's when you would put in wsgi_app.last_request_uri = 'your-url'
. Don't worry about the state or other query params--the URL you paste in should be the full contents of your browser at that point--the window that is open to http://localhost:7788/...
--wrapped in quotes.
Entering continue
into the interactive prompt will exit the debugger and let the program complete.
I did everything as described but none of the example code will complete. I must be missing something somewhere.
python3 arlo-download-bycamera.py 401 Client Error: for url: https://my.arlo.com/hmsweb/users/devices
{"success":false,"data":{"error":"2401","message":"Access token is empty or unauthorized request","reason":"Empty token"}}
Getting this error now: The states do not match as shown in the browser URL window.
EDIT: I had to close the open browser window and let it open a new browser session. However, still getting the 401 Client error above when running any example code. Ooops, forgot to add the path to credentials to the code. OK now. But...
(Pdb) wsgi_app.last_request_uri= 'http://localhost:7788/?state=FCPXprkaH0YtNYqqjxic0etBSkURTV&code=4%2F0AX4XfWiOsm90p6QmG0YMtQfXxaXU9l__2QSciHW_ka2XfOF6z29f6q4N62E8zyJYC7gjnw&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.readonly/'
(Pdb) continue
Traceback (most recent call last):
File "gmail_oauth.py", line 24, in
OK, I finally got all the way through and the example code returns nothing.
Does this require a paid Arlo cloud account to do anything? Just asking.
Belkin just announced new Thread and Matter compliant devices. Looks like Arlo may be doomed. A lot of $ went to Arlo already. Good hardware. Awful management.
The example code does not reflect the MFA work ... change it to use
def LoginMFA(self, username, password, google_credential_file)
actually scrap that .... this is what I meant
class Arlo (username, password, google_credential_file)
https://github.com/jeffreydwalter/arlo/tree/master/docs#classes
This works https://github.com/jeffreydwalter/arlo/blob/master/examples/arlo-setmode.py
change
arlo = Arlo(USERNAME, PASSWORD)
to
arlo = Arlo(USERNAME, PASSWORD, path-to-gmail-creds)
Guess I got myself too far into a work in progress. It’s something I can really use.
python3 arlo-streamingvideo.py
File "arlo-streamingvideo.py", line 15 def LoginMFA(self, username, password, google_credential_file) ^ SyntaxError: invalid syntax
On Jan 4, 2022, at 10:35 PM, cgmckeever @.***> wrote:
def LoginMFA(self, username, password, google_credential_file)
Old engineer who was a whiz at BASIC and FORTRAN.
It works, just needs a hand here or there.
Can you get the mode working that I linked earlier? Start small before you jump right into streaming .. just to make sure you have the plumbing in order.
Still returns nothing. Still wondering if I need a paid Arlo account.
you def do not
Can you add
print(basestations)
right after
basestations = arlo.GetDevices('basestation')
nothing, no errors or anything to go on.
On Jan 4, 2022, at 11:35 PM, cgmckeever @.***> wrote:
Can you add
print(basestations) right after
basestations = arlo.GetDevices('basestation') — Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005375852, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTBOJD5ASVBVV3M66UDUUPDAPANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
even with that print added?
are you getting an email with your MFA code? If you arent getting an email, then thats no good
Nope, only if I login manually and request it.
On Jan 4, 2022, at 11:39 PM, cgmckeever @.***> wrote:
are you getting an email with your MFA code? If you arent getting an email, then thats no good
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005377341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTA7XZKNQHYFRMA7NILUUPDQRANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
if you arent getting a MFA email when you run any of those scripts, there is something broken .. You've copied the gmail-creds file and added it to the main arlo call? Can you post your code snippet?
I can try going though the Google API process again. Tomorrow.
Thanks for the help.
K
On Jan 4, 2022, at 11:39 PM, cgmckeever @.***> wrote:
are you getting an email with your MFA code? If you arent getting an email, then thats no good
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005377341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTA7XZKNQHYFRMA7NILUUPDQRANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
Did all that.
On Jan 4, 2022, at 11:42 PM, cgmckeever @.***> wrote:
if you arent getting a MFA email when you run any of those scripts, there is something broken .. You've copied the gmail-creds file and added it to the main arlo call? Can you post your code snippet?
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005378346, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTEVQMPNB6RZZL4GSBTUUPD4DANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
from arlo import Arlo
username = @.***' password = ‘REDACTED' google_credential_file = '/home/pi/arlo/gmail.credentials'
try:
# Subsequent successful calls to login will update the oAuth token.
# arlo = Arlo(USERNAME, PASSWORD)
arlo = Arlo(username, password, google_credential_file)
# At this point you're logged into Arlo.
# Get the list of devices and filter on device type to only get the basestation.
# This will return an array which includes all of the basestation's associated metadata.
basestations = arlo.GetDevices('basestation')
print(basestations[0])
# Arm Arlo.
arlo.Arm(basestations[0])
# Or
# Disarm Arlo.
# arlo.Disarm(basestations[0])
# Or
# Change Mode to some custom mode you created.
# arlo.CustomMode(basestations[0], "mode3") # 'mode3' is the id of a custom mode you created.
# Or
# Change Mode to Schedule.
# arlo.CustomMode(basestations[0], mode=None, schedules=['schedules.1']) # 'schedules.1' is the id of my default schedule."
except Exception as e: print(e) arlo-setmode.py (END)
tried first with print(basestations) No difference.
On Jan 4, 2022, at 11:43 PM, Kevin Kenyon @.***> wrote:
Did all that.
On Jan 4, 2022, at 11:42 PM, cgmckeever @. @.>> wrote:
if you arent getting a MFA email when you run any of those scripts, there is something broken .. You've copied the gmail-creds file and added it to the main arlo call? Can you post your code snippet?
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005378346, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTEVQMPNB6RZZL4GSBTUUPD4DANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
ahh h.... this bit me .. take the try/except lines out ... there was this weird primary MFA error that I didnt catch till I removed the error handling
python3 arlo-setmode.py
Traceback (most recent call last):
File "arlo-setmode.py", line 10, in
Still no gmail.
On Jan 4, 2022, at 11:50 PM, cgmckeever @.***> wrote:
ahh h.... this bit me .. take the try/except lines out ... there was this weird primary MFA error that I didnt catch till I removed the error handling
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005380678, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTGP5SAZVFQKSIQJZBTUUPE2VANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
YES I know this issue!
Under Account -> Two Factor Auth Make sure your email you synced in the auth process is the one checked
@jeffreydwalter I think this is a semi-bug introduced with this issue/merge .. Why the try/catch doesnt actually catch it is unknown to me. Note the above where error was finally seem remove the try/catch
I only have one email account listed in Arlo so that’s not an issue.
On Jan 4, 2022, at 11:57 PM, cgmckeever @.***> wrote:
Under Account -> Two Factor Auth Make sure your email you synced in the auth process is the one checked
https://user-images.githubusercontent.com/513738/148162741-349f70be-3b7d-4f08-99b4-757c3649f4c7.png — Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005382785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTCCKSYKVSAIS3JKENLUUPFURANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
does it have a check mark?
Not sure if it did when I did the initial authorization. Usually use SMS to my iphone.
On Jan 5, 2022, at 12:03 AM, cgmckeever @.***> wrote:
does it have a check mark?
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005384832, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTF3SKLDDFCPJQJB3SDUUPGLDANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
did you check? Log in via the web UI
It does now.
python3 arlo-setmode.py
Traceback (most recent call last):
File "arlo-setmode.py", line 10, in
On Jan 5, 2022, at 12:13 AM, cgmckeever @.***> wrote:
did you check? Log in via the web UI
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005388522, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTAZJA7EDHEMFEGFGTLUUPHQVANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
did you get the MFA email?
Yes! Progress!
On Jan 5, 2022, at 12:18 AM, cgmckeever @.***> wrote:
did you get the MFA email?
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005390449, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTFHOXDKVFMQCLTJMADUUPIDHANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
Nice .. OK .. now Im lost, the only thing I can think of is that you are using the file from step 6 and not from step 7 https://github.com/jeffreydwalter/arlo/wiki/Configuring-MFA-via-Gmail
or you have authorized the wrong email to allow the read-only access (to slurp out the MFA code)
Nope. I’m sure it’s pointing to the gmail.credentials file that was created by gmail_oauth.py
On Jan 5, 2022, at 12:20 AM, cgmckeever @.***> wrote:
Nice .. OK .. now Im lost, the only thing I can think of is that you are using the file from step 6 and not from step 7 https://github.com/jeffreydwalter/arlo/wiki/Configuring-MFA-via-Gmail https://github.com/jeffreydwalter/arlo/wiki/Configuring-MFA-via-Gmail — Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005391201, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTDTID5OGCIJLHOVAHTUUPIK3ANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
Nope, I know I selected @. @.> when I logged in during gmail_oauth.py
On Jan 5, 2022, at 12:21 AM, cgmckeever @.***> wrote:
or you have authorized the wrong email to allow the read-only access (to slurp out the MFA code)
— Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005391474, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTHKPB4D373KBBGA4TDUUPINTANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
yeah, but lost here now. It looks like its a auth mismatch so wrong email or something... googling that error leads to some rabbit holes that probably can help .. but hard on my side to diagnose
The credentials do not contain the necessary fields need to refresh the access token
I’ll start over tomorrow.
On Jan 5, 2022, at 12:26 AM, cgmckeever @.***> wrote:
yeah, but lost here now. It looks like its a auth mismatch so wrong email or something... googling that error leads to some rabbit holes that probably can help .. but hard on my side to diagnose
The credentials do not contain the necessary fields need to refresh the access token — Reply to this email directly, view it on GitHub https://github.com/jeffreydwalter/arlo/issues/180#issuecomment-1005393372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF4WTTFEYK4Q32TVT4JTSU3UUPI7LANCNFSM5KMVIZ4A. You are receiving this because you authored the thread.
less gmail.credentials
<80>^Ccgoogle.oauth2.credentials Credentials q^@)<81>q^A}q^B(X^E^@^@***@***.***^CXThats what mine looks like .. more or less
Success!!!
I probably screwed up copying the URL from the browser window. Works now. Thanks for the copious help you provided.
In this code, what number should I put in for the array item? I have a printout of my cameras and basestations array. Is this just the element order in each of the arrays. Right now it doesn't return anything. I have three cameras with basestations and a wireless doorbell (no basestation) on that account. The doorbell doesn't show up in the arrays generated.
url = arlo.StartStream(basestations[0], cameras[0])
I havent actually done anything with individual cameras.
I would use the def GetCameraState(self, basestation)
or def GetDevice(self, device_name)
or one of the other calls to naroow in one what is what .. but you got passed the hard part!
`
yes, camera INDEX is just the order in that array
@rsullivan00 since you seem to enjoy wrestling with the gmail-auth ;) ... Have you hit a wall with a 7-day token expirey? I have automated job that turns on my cameras, but it started to fail, from what seems to be this
https://github.com/jeffreydwalter/arlo/pull/160#issuecomment-1008560952
Please answer these questions before submitting your issue. Thanks!
What version of Python are you using (
python -V
)?Python 3.9.9
What operating system and processor architecture are you using (
python -c 'import platform; print(platform.uname());'
)?uname_result(system='Darwin', node='MacBook-Pro.local', release='21.2.0', version='Darwin Kernel Version 21.2.0: Sun Nov 28 20:28:41 PST 2021; root:xnu-8019.61.5~1/RELEASE_ARM64_T6000', machine='arm64')
Which Python packages do you have installed (run the
pip freeze
orpip3 freeze
command and paste output)?Which version of ffmpeg are you using (
ffmpeg -version
)?Which Arlo hardware do you have (camera types - [Arlo, Pro, Q, etc.], basestation model, etc.)?
Pro2 w/basestation, Ultra w/basestation, Wireless Doorbell (no basestation)
What did you do?
Followed docs. Get to screen where Google asks for permission then it dies with a localhost:7788 not found error
What did you expect to see?
generate credentials file
What did you see instead?
dies
Does this issue reproduce with the latest release?
Yes, all up to date.
Looks like a problem with serving localhost:7788 from my Mac. localhost alone does respond.
Traceback (most recent call last): File "/Users/private/arlo/gmail_oauth.py", line 20, in
credentials = flow.run_local_server(host='localhost',
File "/opt/homebrew/lib/python3.9/site-packages/google_auth_oauthlib-0.4.6-py3.9.egg/google_auth_oauthlib/flow.py", line 476, in run_local_server
authorization_response = wsgi_app.last_request_uri.replace("http", "https")
AttributeError: 'NoneType' object has no attribute 'replace'
So close yet so far...
Kevin