The Wayback Machine - https://web.archive.org/web/20200906101602/https://github.com/jwt/ruby-jwt/issues/186/
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

can't create token - 'NotImplementedError: Unsupported signing method' #186

Closed
Jpease1020 opened this issue Jan 31, 2017 · 4 comments
Closed

Comments

@Jpease1020
Copy link

@Jpease1020 Jpease1020 commented Jan 31, 2017

when I run this code,

payload = 'username'
hmac_secret = 'my$ecretK3y'
token = JWT.encode payload, hmac_secret, 'HS256'

I get this error JSON::GeneratorError: only generation of JSON objects or arrays allowed

I am using ruby version 2.3.0 in a rails 4.2.6 project

@Jpease1020 Jpease1020 changed the title can't create token can't create token - JSON::GeneratorError: only generation of JSON objects or arrays allowed Jan 31, 2017
@excpt
Copy link
Member

@excpt excpt commented Jan 31, 2017

Your payload needs to be a hash.

payload = {
    username: 'username'
}
@Jpease1020
Copy link
Author

@Jpease1020 Jpease1020 commented Jan 31, 2017

I changed the payload to

payload = { username: 'username' }

and ran

payload = { username: 'username' }
hmac_secret = 'my$ecretK3y'
JWT.encode(payload, hmac_secret, "H256")

and I get this error

NotImplementedError: Unsupported signing method

@Jpease1020 Jpease1020 changed the title can't create token - JSON::GeneratorError: only generation of JSON objects or arrays allowed can't create token - 'NotImplementedError: Unsupported signing method' Jan 31, 2017
@Jpease1020 Jpease1020 closed this Jan 31, 2017
@HimaChitalia
Copy link

@HimaChitalia HimaChitalia commented Aug 23, 2017

@Jpease1020 Were you able to solve this? I am having same issue!

@excpt
Copy link
Member

@excpt excpt commented Aug 24, 2017

@HimaChitalia

Have you checked for typos? Sometimes I catch myself fast typing H256 instead of HS256 or E512 instead of ES512.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.