With a certain token, if I run:
JWT.decode token, nil, false
... I get a decoded token as expected. the type ('typ') is "JWT", the 'alg' is "RS256", and the expected public key is in "kid".
However, if I run
JWT.decode token, rsa_public_key, true, { algorithm: 'RS256' }
... with the same token, and for "rsa_public_key" the public key in "kid" results from first run, I get a failure:
Traceback (most recent call last):
16: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
15: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/cli.rb:27:in `dispatch'
14: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
13: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
12: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
11: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/cli.rb:424:in `exec'
10: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:28:in `run'
9: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `kernel_load'
8: from _hiddenpath_/.gem/ruby/2.5.0/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `load'
7: from /usr/bin/irb:11:in `<top (required)>'
6: from (irb):5
5: from _hiddenpath2_/vendor/bundle/ruby/2.5.0/gems/jwt-2.1.0/lib/jwt.rb:32:in `decode'
4: from _hiddenpath2_/vendor/bundle/ruby/2.5.0/gems/jwt-2.1.0/lib/jwt.rb:47:in `decode_verify_signature'
3: from _hiddenpath2_/vendor/bundle/ruby/2.5.0/gems/jwt-2.1.0/lib/jwt/signature.rb:42:in `verify'
2: from _hiddenpath2_/vendor/bundle/ruby/2.5.0/gems/jwt-2.1.0/lib/jwt/algos/rsa.rb:15:in `verify'
1: from _hiddenpath2_/vendor/bundle/ruby/2.5.0/gems/jwt-2.1.0/lib/jwt/security_utils.rb:20:in `verify_rsa'
NoMethodError (undefined method `verify' for "_my_public_rsa":String)
Any suggestions on what is wrong? This happens in both irb and when running ruby scripts outside of irb. I have run 'bundle install', and of course required 'jwt' in all situations. Everything else besides this seems to be in order.