summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Padilla <jpadilla@webapplicate.com>2015-04-15 16:37:20 -0400
committerJosé Padilla <jpadilla@webapplicate.com>2015-04-15 16:37:20 -0400
commit60ee6f23b30f766620266aae90c751ac2d544f03 (patch)
treef9c024c38adacb0f33afb64da46243fecddf678e
parent5ecc66d71a47cf714be5984ecefd2d81058b033f (diff)
parent7d15be7fa28324ad7ac34390c3d724fa2e728385 (diff)
downloadpyjwt-60ee6f23b30f766620266aae90c751ac2d544f03.tar.gz
Merge pull request #128 from nielsdraaisma/master
Fixed command line encoding
-rwxr-xr-xbin/jwt27
1 files changed, 14 insertions, 13 deletions
diff --git a/bin/jwt b/bin/jwt
index 2f8326c..22aedc6 100755
--- a/bin/jwt
+++ b/bin/jwt
@@ -71,21 +71,22 @@ The exp key is special and can take an offset to current Unix time.
options, arguments = p.parse_args()
if len(arguments) > 0 or not sys.stdin.isatty():
- # Try to decode
- try:
- if not sys.stdin.isatty():
- token = sys.stdin.read()
- else:
- token = arguments[0]
+ if len(arguments) == 1 and ( options.verify is False or options.key is not None ):
+ # Try to decode
+ try:
+ if not sys.stdin.isatty():
+ token = sys.stdin.read()
+ else:
+ token = arguments[0]
- token = token.encode('utf-8')
- data = jwt.decode(token, key=options.key, verify=options.verify)
+ token = token.encode('utf-8')
+ data = jwt.decode(token, key=options.key, verify=options.verify)
- print(json.dumps(data))
- sys.exit(0)
- except jwt.DecodeError as e:
- print(e)
- sys.exit(1)
+ print(json.dumps(data))
+ sys.exit(0)
+ except jwt.DecodeError as e:
+ print(e)
+ sys.exit(1)
# Try to encode
if options.key is None: