-
Notifications
You must be signed in to change notification settings - Fork 24
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
403 Forbiden #57
Comments
Please try to change MD5 Digest Algorithm to something different (and show me all the options), because I don't know which one is being used by my cameras since I don't have the same settings as you. |
Okay, looks like my cam also uses MD5 and it works. Can you please replace content of this file https://github.com/tropicoo/hikvision-camera-bot/blob/da14bc66fd7a6ba217f21b70d75ef3d6331901ee/hikcamerabot/clients/hikvision/auth.py with this, rebuild the container and show me the logs (there shouldn't be your password visible, but please double check. import logging
from typing import Generator
import httpx
log = logging.getLogger()
class DigestAuthCached(httpx.DigestAuth):
"""Hack from https://github.com/encode/httpx/issues/1467."""
__challenge = None
def auth_flow(
self, request: httpx.Request
) -> Generator[httpx.Request, httpx.Response, None]:
if self.__challenge:
request.headers['Authorization'] = self._build_auth_header(
request, self.__challenge
)
log.critical('Challenge: %s', self.__challenge)
log.critical('Request headers: %s', request.headers)
log.critical('Request headers: %s', request.headers)
response = yield request
log.critical('Response headers: %s', response.headers)
if response.status_code != 401 or 'www-authenticate' not in response.headers:
# If the response is not a 401 then we don't
# need to build an authenticated request.
return
for auth_header in response.headers.get_list('www-authenticate'):
if auth_header.lower().startswith('digest '):
break
else:
# If the response does not include a 'WWW-Authenticate: Digest ...'
# header, then we don't need to build an authenticated request.
return
self.__challenge = self._parse_challenge(request, response, auth_header)
request.headers['Authorization'] = self._build_auth_header(
request, self.__challenge
)
log.critical('Request headers after build: %s', request.headers)
log.critical('Request auth details: %s', request.headers['authorization'])
yield request |
|
Can you try to keep the first option
to auth=httpx.BasicAuth( and check whether it works for you. |
I have modified file, i have try with setting
i have try with setting
question could there be a certificate problem? when I enter on a web page, i have the certificate message Update : same when i try direcly on cam , i successfuly get cam picture but other nothing Config :
log :
|
Maybe some NVR security settings forbid us to do API calls since we can see that when the auth fails we have 401 Unauthorized code and 403 Forbidden (when authorization probably succeeds). What we can also try is to add a log for the response data: After that line add self._log.debug('Response data: %s - %s', response.headers, response.data) |
User is admin and have full acces i have add your line :
on NVR API is enable (i have add user admin but same result) : on service network i have https / TLS / SDK / RTPS / Websocket and IOT : on camera i have actived Hikvision-CGI for try (same result) and on camera i have try disable HTTPS for only http wihtout certificat but same result : |
I don't see a log message in your reply Is there any way to access your camera directly without going through NVR? |
i have disable HTTPS/TLS but same result ever 403 Forbiden. I have rebuild, maybe error in line ?
|
Ah, please change |
When i add this code after line 57 i have that :
or that if i don't line up
|
Yes, i have tab problem, sorry for that Line Detection :
Motion Detection :
if i put direct link in web i have that :
|
Which exact direct link did you use?
|
Sorry for delay answer, port 30443 it's https, 65002 it's internal cam 2 port and 80 http port i cam talk with camera directly with internal port, https and http talk with NVR |
Dear,
Thank you very much for your work !
i have install and try to use it, it work fine to receive images on request. However, when I try to control the activation of the cameras via the telegram bot (line detection, motion detection...) I constantly receive Forbiden 403 errors. Yet I have well informed the login / pass in the config. Note that the cameras are behind an NVR. Is there a specific thing to do to fix this problem?
The text was updated successfully, but these errors were encountered: