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

JWT token loaded from a file #4

Closed
metanav opened this issue Sep 29, 2015 · 6 comments
Closed

JWT token loaded from a file #4

metanav opened this issue Sep 29, 2015 · 6 comments

Comments

@metanav
Copy link

metanav commented Sep 29, 2015

It would be more useful to have (the bulky) JWT token be loaded from a file.

@flazzarini
Copy link

You could use bash to read the token from a file

http --auth-type=jwt --auth='$(cat mytoken.txt):' example.org

@metanav
Copy link
Author

metanav commented Sep 29, 2015

Thanks! BTW, It worked after removing single quotes.

@hoatle
Copy link
Member

hoatle commented Sep 29, 2015

thank you @flazzarini for your help.

@metanav: I've added the question here to FAQs section at https://github.com/teracyhq/httpie-jwt-auth/tree/develop#faqs

@ibqn
Copy link

ibqn commented Dec 20, 2016

If you use bash shell you should use double quotes (") instead of single ones('), it is very crutial here!

You could use bash to read the token from a file

http --auth-type=jwt --auth="$(cat mytoken.txt):" example.org

https://stackoverflow.com/questions/6697753/difference-between-single-and-double-quotes-in-bash

@hoatle
Copy link
Member

hoatle commented Feb 7, 2017

thank you @ibqn, I've updated the README file to use double quotation marks

@dragon788
Copy link

It would be nice to have the simple --auth=@filename syntax like httpie uses for loading JSON data, but the "$(cat auth.token)" works pretty well. One thing to note is that if you were using something like http POST https://my.domain.com/auth/gettoken | jq .id_token > auth.token you might have issues. In this case you need to pass the -r to jq so that it removes double quotes before outputting the value, otherwise in the file you have literally "veryLongJWTString" with the double quotes, which makes it not a valid JWT anymore, so jq -r .id_token > auth.token will get you a valid JWT you can use with "$(cat auth.token)" and this plugin.

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

No branches or pull requests

5 participants