Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

DioError 403 with correct URL, username, password #20

Closed
Whisprin opened this issue Dec 8, 2020 · 10 comments
Closed

DioError 403 with correct URL, username, password #20

Whisprin opened this issue Dec 8, 2020 · 10 comments

Comments

@Whisprin
Copy link

Whisprin commented Dec 8, 2020

Hello,

I'm trying to setup the app and connect to my paperless instance.

I'm using a password manager to copy&paste the URL, username and password of my instance - so they should be correct.
The URL is something like: https://paper.host.tld/paperless/ and the login in the browser is successful as well.

However, in the app I'm getting this Error:

"Error while connecting to server"
DioErro [DioErrorTyoe.RESPONSE]: Http status error [403]

@bauerj
Copy link
Owner

bauerj commented Dec 8, 2020

Hey Robert,

do you use a reverse proxy in front of paperless?

@Whisprin
Copy link
Author

Whisprin commented Dec 9, 2020

I'm using Apache and mod_wsgi like described here: https://paperless.readthedocs.io/en/latest/setup.html#making-things-a-little-more-permanent
But I changed Alias to /paperless/static and WSGIScriptAlias to /paperless.

@bauerj
Copy link
Owner

bauerj commented Dec 9, 2020

Can you confirm that

curl --user <username> https://paper.host.tld/paperless/api/documents/

works? It should return a long list of documents.

Edit: This originally did not include the slash at the end.

@jonaswinkler
Copy link

jonaswinkler commented Dec 9, 2020

Can you confirm that

curl --user <username> https://paper.host.tld/paperless/api/documents

works? It should return a large list of documents.

Don't forget trailing slashes. I think they are required.

@Whisprin
Copy link
Author

Whisprin commented Dec 9, 2020

Using curl I get a redirect to location: /paperless/api/documents/ and then the same error:

< HTTP/2 403
{"detail":"Authentication credentials were not provided."}

With correct, incorrect and no password it's the same response.

When I open this URL logged in the browser it works:

GET /paperless/api/documents/

HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 44,
    "next": "https://paper.host.tld/paperless/api/documents/?page=2",
    "previous": null,
    "results": [
        {
            "id": 28,
            "correspondent": null,
            "title": "0120",
...

@bauerj
Copy link
Owner

bauerj commented Dec 9, 2020

Thanks for confirming. This looks like a server issue then. The browser uses a different authentication mechanism with cookies which is why it works fine there.

It's not quite clear to me why this doesn't work but then again I don't work much with Apache.

@jonaswinkler
Copy link

jonaswinkler commented Dec 9, 2020

try

curl --user <username> --basic https://paper.host.tld/paperless/api/documents/

which should ask you for your password and verify that authentication works.

@Whisprin
Copy link
Author

Whisprin commented Dec 9, 2020

Thanks, yes with and also without --basic the password prompt appears:

Enter host password for user 'myuser':

The response is the same as above.

@Whisprin
Copy link
Author

Whisprin commented Dec 9, 2020

I got it!
Thanks for nudging me in the right direction. I didn't know that the API uses basic auth.

In order to have basic auth working with wsgi this is needed in the apache conf: WSGIPassAuthorization On.

https://www.django-rest-framework.org/api-guide/authentication/#setting-the-authentication-scheme

Created a PR to the documentation. Now on to try the app :)

@Whisprin Whisprin closed this as completed Dec 9, 2020
@bauerj
Copy link
Owner

bauerj commented Dec 9, 2020

Thanks for posting the solution! This should probably be changed in the documentation(s).

Edit: I see you're already one step ahead here 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants