zoedsoupe
I have this Guardian module:
defmodule Sntx.Guardian do
use Guardian, otp_app: :sntx
alias Sntx.Repo
alias Sntx.User.Account
def subject_for_token(user, _claims) do
sub = to_string(user.id)
{:ok, sub}
end
def resource_from_claims(claims) do
user = Repo.get(Account, claims["sub"])
{:ok, user}
end
def after_encode_and_sign(resource, claims, token, _options) do
with {:ok, _} <- Guardian.DB.after_encode_and_sign(resource, claims["typ"], claims, token) do
{:ok, token}
end
end
def on_verify(claims, token, _options) do
with {:ok, _} <- Guardian.DB.on_verify(claims, token) do
{:ok, claims}
end
end
def on_refresh({old_token, old_claims}, {new_token, new_claims}, _options) do
with {:ok, _, _} <- Guardian.DB.on_refresh({old_token, old_claims}, {new_token, new_claims}) do
{:ok, {old_token, old_claims}, {new_token, new_claims}}
end
end
def on_revoke(claims, token, _options) do
with {:ok, _} <- Guardian.DB.on_revoke(claims, token) do
{:ok, claims}
end
end
end
Then, if I try to execute Sntx.Guardian.encode_and_sign(%{id: "123"}) I receive this error:
** (CaseClauseError) no case clause matching: 43
(jose 1.11.5) src/base/jose_base64url.erl:136: :jose_base64url."-decode!/2-lbc$^0/2-0-"/2
(jose 1.11.5) src/base/jose_base64url.erl:136: :jose_base64url.decode!/2
(jose 1.11.5) src/jwk/jose_jwk_kty_oct.erl:50: :jose_jwk_kty_oct.from_map/1
(jose 1.11.5) src/jwk/jose_jwk.erl:304: :jose_jwk.from_map/1
(jose 1.11.5) lib/jose/jwk.ex:140: JOSE.JWK.from_map/1
(guardian 2.3.1) lib/guardian/token/jwt.ex:272: Guardian.Token.Jwt.create_token/3
(guardian 2.3.1) lib/guardian.ex:776: Guardian.returning_tuple/1
(guardian 2.3.1) lib/guardian.ex:602: Guardian.encode_and_sign/4
I’m really confused about this error. Any idea that what this means?
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
So i have been using ash framework for a while and i love it. However currently the issue im having with ash framework is the error handl...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
zoedsoupe
There is a public repo here: https://github.com/zoedsoupe/sntx, on branch
feature/blog-postsal2o3cr
The basic cause is that a
+character (byte value 43) appears in a string that:jose_jwk.from_map/1treats as encoded in URL-safe Base64, which doesn’t allow that character. That behavior is directly from the specification forkty=oct.The root cause is that this incorrectly-encoded value is being set in
config/config.exsfrom an environment variable: https://github.com/zoedsoupe/sntx/blob/feature/blog-posts/config/config.exs#L30adamu
Not directly answering your question, but just in case
zoedsoupe
Oh thank you! I generated the token with
mix guardian.gen.secretbut it seem was generated with a+char!al2o3cr
Yeah, that’s a tricky one - the sets of characters used by
encode64andurl_encode64are nearly the same, so you got a bad roll of the dice.I created an issue on Guardian to address / document this:
https://github.com/ueberauth/guardian/issues/718