Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error requesting networks #329

Closed
tsolid opened this issue Jul 10, 2020 · 12 comments · Fixed by #331
Closed

Error requesting networks #329

tsolid opened this issue Jul 10, 2020 · 12 comments · Fixed by #331
Labels
blink-api-issue There is an issue with the Blink API that needs to be addressed before the issue can be solved priority This should be a focus for the next major release

Comments

@tsolid
Copy link

tsolid commented Jul 10, 2020

I have been running 0.15 for over a week now and no issues, but yesterday it started to error on self.get_networks()

Traceback (most recent call last):
  File "scripts/grab-photo.py", line 9, in <module>
    blink.start()
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/blinkpy.py", line 135, in start
    self.get_auth_token()
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/blinkpy.py", line 176, in get_auth_token
    self.setup_params(self.login_response)
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/blinkpy.py", line 189, in setup_params
    self.networks = self.get_networks()
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/blinkpy.py", line 195, in get_networks
    response = api.request_networks(self)
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/api.py", line 82, in request_networks
    return http_get(blink, url)
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/api.py", line 301, in http_get
    is_retry=is_retry,
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/helpers/util.py", line 104, in http_req
    if json_resp and "code" in response.json():
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/python3/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/python3/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/python3/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I thought it might be the version, so I updated to the latest dev build. I had to enter in a new code but now i'm still getting a similar error:

Expected json response from https://rest-u003.immedia-semi.com/api/v3/accounts/XXXXX/homescreen, but received: 403: Forbidden
Enter code sent to XXXX@gmail.com: XXXXXX
Traceback (most recent call last):
  File "scripts/grab-photo2.py", line 13, in <module>
    blink.start()
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/blinkpy.py", line 114, in start
    self.setup_prompt_2fa()
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/blinkpy.py", line 121, in setup_prompt_2fa
    result = self.auth.send_auth_key(self, pin)
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/blinkpy/auth.py", line 207, in send_auth_key
    json_resp = response.json()
  File "/var/services/homes/admin/.local/lib/python3.7/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/python3/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/python3/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/python3/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
@locvez
Copy link

locvez commented Jul 10, 2020

I think the API has been disabled / changed. I also get a 403 forbidden with another blink video download script. Everything was working fine until yesterday aftenoon

@alistairwatts
Copy link

alistairwatts commented Jul 10, 2020

I'm also getting the first traceback.

On further investigation I've found that when the library is POSTing to https://rest-prod.immedia-semi.com/api/v4/login it is resulting in a an HTTP 404 error.

@apepelis
Copy link

madshall/node-blink-security#52

there are some comments in the nodejs version about errors. mine stopped working yesterday at 5:17pm est.

@anonymous-one
Copy link

The end points have moved from rest.___ to rest-____.

I was able to fix the nodejs version I am running in the above link.

@fronzbot
Copy link
Owner

@anonymous-one that change happened almost a year ago. This library has been using that updated endpoint since then. The only endpoint currently working is login (at least based on my testing).

@fronzbot fronzbot added blink-api-issue There is an issue with the Blink API that needs to be addressed before the issue can be solved priority This should be a focus for the next major release labels Jul 11, 2020
@apepelis
Copy link

so the code already connects to:
https://rest-prod.immedia-semi.com/api/v3/login
to log in and then when it calls those:
str: https://rest-u020.immedia-semi.com/networks
it gets back JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@apepelis
Copy link

yeah, the log in one is the only one that looks like it works to me.

@alistairwatts
Copy link

My earlier debugging was off (it was late) - https://rest-prod.immedia-semi.com/api/v4/login is giving a 404, but https://rest-prod.immedia-semi.com/api/v3/login is giving a 200.

Once login has worked, GETting https://rest-prde.immedia-semi.com/networks is returning a 403.

@anonymous-one
Copy link

ah. i apologize, looks like the nodejs api handler was using the old end points... which worked fine until yesterday.

perhaps a coincidence but its strange that on the same day the rest.___ end points stop working this python handler starts having issues...

regardless, using the nodejs version everything is working fine for me.

@anonymous-one that change happened almost a year ago. This library has been using that updated endpoint since then. The only endpoint currently working is login (at least based on my testing).

@tsolid
Copy link
Author

tsolid commented Jul 11, 2020

I was following @anonymous-one in the node-js api thread and he has found a fix!

Remove / comment out all instances of "Host: ..." for each of the request.post blocks.

I was able to do this in the dev build (v0.16.0-rc11) by editing auth.py:

Change Line 56 from:
return {"Host": self.host, "TOKEN_AUTH": self.token}
to:
return {"TOKEN_AUTH": self.token}

and it worked!!

I can submit a PR later tonight but need to get back to stuff I promised my wife would get done :)

@alistairwatts
Copy link

I've just made the same change locally and it seems to be working. Thanks.

@locvez
Copy link

locvez commented Jul 11, 2020

thanks for that info tsolid. I have also applied a fixed pull request to nayrk/Blink to fix the powershell version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blink-api-issue There is an issue with the Blink API that needs to be addressed before the issue can be solved priority This should be a focus for the next major release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants