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
Argument error when generating token #247
Comments
It seems that your PEM is not properly formatted. You are using single quotes ( Try setting your PEM like: config :joken,
rsa_key: [
signer_alg: "RS256",
key_pem: """
-----BEGIN PUBLIC KEY-----
....
-----END PUBLIC KEY-----
"""
] It is important that the final triple quotes be aligned with where each starts so that Elixir will trim it automatically. Please tell me if that works |
Hey @victorolinasc !
Could it be a badly sanitized private key? |
That is strange.... Try this please: %Joken.Signer{} = signer = Joken.Signer.parse_config(:rsa_key)
defmodule MyToken do
use Joken.Config
def token_config, do: %{}
end
token = "xxxxx"
MyToken.verify_and_validate(token, signer) |
I already figured it out. I was missing the token_config argument in the |
Nice! Can I close this then? |
Actually one more question, how do I need to format the private key in an ENV variable in order for Elixir to trim it correctly? |
It must be a valid PEM string. PEM can be split into multi lines or not. THe issue you had first was that your multi-line PEM had spaces at the beginning of the lines because of the single quote. So, if the PEM is on an ENV variable it just needs to be a valid PEM file. |
@pedroseabra1091 I'll be closing this one. If you need any help feel free to re-open it. |
When generating the token while defining the signer explicitly I get:
I am currently creating the signer through the config file like stated in (https://hexdocs.pm/joken/assymetric_cryptography_signers.html#content):
The text was updated successfully, but these errors were encountered: