Rooyca / obsidian-api-request

Obsidian plugin that allows you to make requests to API's and receive responses in codeblocks or store them in localStorage.
https://rooyca.github.io/obsidian-api-request/
MIT License
78 stars 4 forks source link

Basic auth not working #21

Closed bryceprutsos closed 4 weeks ago

bryceprutsos commented 4 weeks ago

Describe the bug When using a basic auth Get request it comes back as 401 error even though it comes back successful in Postman

To Reproduce

Expected behavior Come back with information

Screenshots If applicable, add screenshots to help explain your problem. Obsidian Code image Postman Code image

image

Additional context These calls seem the exact same but I am not sure why I am getting a 401.

Rooyca commented 4 weeks ago

I believe the problem is a missing space after headers:

```req
url: ...
headers: {...} 
```

P.S. I'll fix this in the next update. Sorry about that.

bryceprutsos commented 4 weeks ago

Yes that was right thanks for helping I was trying all sorts of stuff before putting in this bug. Quick question for the future if I had multiple headers like having to add "Accept": "application/json" as well how would that look in the call?

Rooyca commented 4 weeks ago

This is something that needs to be fix. Thanks for letting me know.

if I had multiple headers like having to add "Accept": "application/json" as well how would that look in the call?

It should looks something like:

```req
url: https://example.com
headers: {"Accept": "application/json", "Authorization": "Basic XXXXX"}
```

I think so... if that doesn't work try removing the space after the comma.

Either way I'll be addressing this problem (spaces, or not spaces, that is the question) in the next release.

Rooyca commented 4 weeks ago

Hey @bryceprutsos, It should be fix now. Could you check?

bryceprutsos commented 4 weeks ago

Everything is working as expected after the update. I tried with and without the space.