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

Prompt for camera authentication #750

Open
revanreddy opened this issue Apr 5, 2023 · 8 comments
Open

Prompt for camera authentication #750

revanreddy opened this issue Apr 5, 2023 · 8 comments
Labels
question Discussion about functionality

Comments

@revanreddy
Copy link

revanreddy commented Apr 5, 2023

When We load the axis camera on browser it prompts to enter the credentials to get the camera stream. but we want to avoid the prompt and authenticate by passing the credentials through request.

Thanks

@revanreddy revanreddy added the question Discussion about functionality label Apr 5, 2023
@revanreddy revanreddy changed the title Avoid Prompt for camera authentication Prompt for camera authentication Apr 6, 2023
@MennoSaey
Copy link

Have you solved your problem? i am dealing with the same issue.

@revanreddy
Copy link
Author

@MennoSaey No didn't get any.. did you find any way ?

@MennoSaey
Copy link

@revanreddy Sadly i didn't find a solution either. The way we tried to solve it was by sending a simple authenticated request but even when providing the correft headers there was still an issue, I have spoken to someone associated with Axis and they confirmed it is an issue on their end and will work on fixing this.

@revanreddy
Copy link
Author

revanreddy commented Jul 7, 2023

Thanks @MennoSaey for the quick response.. Have you done the PTZ implementation for the Axis camera ?

@MennoSaey
Copy link

@revanreddy No, our implementation only needed to view the cameras. I forgot to mention that if u just want to view the camerafeed, you can send a post request that changes the anonymous viewing to enabled. This way you can view the camerafeed and then disable it again after you are done.

@revanreddy
Copy link
Author

Thanks @MennoSaey. It will be helpful for us :)

@steabert
Copy link
Member

The auth module we have was mostly used for testing purposes and I haven't kept it up-to-date with regards to docs. The digest auth part of it only works in Node.js, if you run it from the command line.

When running in a browser, you cannot intercept digest auth. The only way to do that is to run a proxy that can intercept any digest auth request and provide authentication headers. But that is slightly out-of-scope for this project. I'll have a look if I can find some good example(s) on how to do this. However, note that you then no longer just access the camera directly from the browser.

I have not tested with cameras with basic auth, is that what your camera is set to? In theory, that should work with the provided auth module.

@SampsaKaskela
Copy link

SampsaKaskela commented Nov 30, 2023

You can accomplish this by giving Authorization header in your request. For example when using usergroup.cgi. In this case CORS has to be configured since you can't use no-cors mode like in examples. I have following function that works for me and it uses Basic auth.

const authorize = async (hostname: string) => {
  const response = await window.fetch(`http://${hostname}/axis-cgi/usergroup.cgi`, {
    credentials: 'include',
    headers: {
      Authorization: `Basic ${window.btoa('username:password')}`,
    },
  });
  if (!response.ok) throw new Error('Failed to get stream');
};

Axis had issue with Authorization header when used with CORS and they have now fixed it in latest firmware release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Discussion about functionality
Projects
None yet
Development

No branches or pull requests

4 participants