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

encode always errors with "Invalid JSON provided!" on 6.0.0 #290

Closed
morremeyer opened this issue Sep 20, 2023 · 2 comments
Closed

encode always errors with "Invalid JSON provided!" on 6.0.0 #290

morremeyer opened this issue Sep 20, 2023 · 2 comments

Comments

@morremeyer
Copy link

Summary

When I try to set an expiration for a token in 6.0.0, it always errors with

❯ jwt encode --secret "@${GITHUB_APP_SECRET_PATH}" -e "+60 sec" -i "${GITHUB_APP_ID}" --alg RS256
thread 'main' panicked at 'Invalid JSON provided!', src/translators/encode.rs:122:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This is on macOS Ventura 13.5.2

Steps to reproduce

Have a valid pem file on your machine. Then, run

export SECRET_PATH="path_to_your_file"

jwt encode --secret "@${SECRET_PATH}" -e "+60 sec" -i "0123456789" --alg RS256
jwt encode --secret "@${SECRET_PATH}" -e "60" -i "0123456789" --alg RS256

and see that both output

thread 'main' panicked at 'Invalid JSON provided!', src/translators/encode.rs:122:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

However,

jwt encode --secret "@${SECRET_PATH}" -i "0123456789" --alg RS256

will work.

Expected behavior

Setting an expiration should work.

@AlexSeefeldt
Copy link

AlexSeefeldt commented Sep 22, 2023

Hi @morremeyer, I had this same issue, and I think I know what the problem is. The -e option requires an equal sign rather than whitespace between the option and the argument (e.g. -e="+60 sec"), so your examples should look like this:

jwt encode --secret "@${SECRET_PATH}" -e="+60 sec" -i "0123456789" --alg RS256
jwt encode --secret "@${SECRET_PATH}" -e="60" -i "0123456789" --alg RS256

Hope this helps.

@mike-engel
Copy link
Owner

Thanks @AlexSeefeldt. This was an ugly side-effect of the update from clap 3 to 4 and the way that expires argument works. It may be able to change back in the future. It's documented in the help output, but it's not incredibly helpful

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

No branches or pull requests

3 participants