Skip to content

refact: handle Authorization as a header#24

Merged
NTBBloodbath merged 2 commits intomainfrom
bugfix/auth-bad-returning
Jun 30, 2021
Merged

refact: handle Authorization as a header#24
NTBBloodbath merged 2 commits intomainfrom
bugfix/auth-bad-returning

Conversation

@NTBBloodbath
Copy link
Copy Markdown
Member

This PR fixes the get_auth function returning value so the Authorization header value will be successfully passed.

@mr-majkel can you please give it a try? I think that issue was by my side. Already passed an Authorization statement like Authorization: Bearer random_characters but I don't have how to properly test it right now, although I think it should work as intended.

Lemme know if the issue is fixed here and if that's the case then let's close the plenary issue regarding to Bearer tokens.

Regards

@NTBBloodbath NTBBloodbath linked an issue Jun 30, 2021 that may be closed by this pull request
@mr-majkel
Copy link
Copy Markdown
Contributor

mr-majkel commented Jun 30, 2021

@NTBBloodbath indeed now the auth table is returned. However, with this request:

POST https://reqres.in/api/users

Authorization: Bearer h3r3_is_sup3r10ng_t0ken!!!111
Content-Type: application/json
{
  "name": "morpheus",
  "job": "leader"
}

preview is showing me this:

[rest.nvim] Request preview:
curl -sSL -D /tmp/plenary_curl_2f4547a9.headers --compressed -X POST -H Content-Type:  application/json --data-raw {"name":"morpheus","job":"leader"} -u 1:Bearer https://reqres.in/api/users

so there is -u flag (user) that is assigned 1:Bearer value. This seems to me to be plenary issue - where they are after username:password pair. What we are after with the token, is the header passed to curl call:

-H Authorization: Bearer h3r3_is_sup3r10ng_t0ken!!!111

edits: typos and a link

@NTBBloodbath
Copy link
Copy Markdown
Member Author

NTBBloodbath commented Jun 30, 2021

Alright, that's a plenary issue then or maybe I'm not understanding that auth field in the plenary cURL wrapper, thanks to trying it out. I think I can do a workaround myself to fix it by passing the authentication header as a header instead of passing it as auth, do you want to try in that way?

@mr-majkel
Copy link
Copy Markdown
Contributor

Considering there is not so big movement on plenary side around my question - I think it's best approach.

I am also a bit confused on the auth field. Maybe the whole reason is that auth is supposed to be used only for -u option in curl, and rest of to-be-headers should be passed to headers table?

@NTBBloodbath
Copy link
Copy Markdown
Member Author

I think so, gimme a moment to modify the files and I'll let you know so you can try it

@NTBBloodbath
Copy link
Copy Markdown
Member Author

Alright, lemme know if it's working now!

@NTBBloodbath NTBBloodbath changed the title fix: get_auth was always returning nil refact: handle Authorization as a header Jun 30, 2021
@mr-majkel
Copy link
Copy Markdown
Contributor

@NTBBloodbath works like a charm:)

@mr-majkel
Copy link
Copy Markdown
Contributor

@NTBBloodbath I will ask you for yet another improvement related to this one:). I will make a separate issue for it, though, so we can discuss properly.

@NTBBloodbath
Copy link
Copy Markdown
Member Author

Thank you for testing it, I'm gonna merge it right now. Just remember to close the plenary issue because it was fixed by our side.

I will ask you for yet another improvement related to this one:). I will make a separate issue for it, though, so we can discuss properly.

Sure, I'm gonna check it out right now, thank you!

@NTBBloodbath NTBBloodbath merged commit 5042edf into main Jun 30, 2021
@NTBBloodbath NTBBloodbath deleted the bugfix/auth-bad-returning branch June 30, 2021 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to use header Authorization: Bearer token

2 participants