Skip to content

Commit 14c9c80

Browse files
authored
add logging for token validation errors (#52)
1 parent f97e473 commit 14c9c80

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- `query_platform/4` now handles all 2xx status codes as success, returning `{:ok, body}` with the raw response body. Previously only `200` responses with a `%{data: data}` GraphQL structure were treated as success, causing non-GraphQL platform APIs (e.g. ACME) to incorrectly fall through to the error path.
13+
- Added logging to `verify_peek_auth/2` and `verify_client_request/2` to help debug token verification failures. Warning messages now include the specific error reason and config_id context.
1314

1415
## [2026-02-27]
1516

lib/peek_app_sdk/token.ex

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule PeekAppSDK.Token do
22
use Joken.Config
3+
require Logger
34

45
alias PeekAppSDK.AccountUser
56
alias PeekAppSDK.Config
@@ -31,10 +32,12 @@ defmodule PeekAppSDK.Token do
3132
{:ok, %{"sub" => sub} = claims} ->
3233
{:ok, sub, claims}
3334

34-
{:error, _reason} ->
35+
{:error, reason} ->
36+
Logger.warning("Token verification failed for config_id=#{inspect(config_id)}: #{inspect(reason)}")
3537
{:error, :unauthorized}
3638

37-
_ ->
39+
other ->
40+
Logger.warning("Token verification failed for config_id=#{inspect(config_id)} with unexpected result: #{inspect(other)}")
3841
{:error, :unauthorized}
3942
end
4043
end
@@ -68,13 +71,16 @@ defmodule PeekAppSDK.Token do
6871
{:ok, %{"sub" => sub} = claims} ->
6972
{:ok, sub, claims}
7073

71-
{:error, _reason} ->
74+
{:error, reason} ->
75+
Logger.warning("Client token verification failed for config_id=#{inspect(config_id)}: #{inspect(reason)}")
7276
{:error, :unauthorized}
7377

74-
_ ->
78+
other ->
79+
Logger.warning("Client token verification failed for config_id=#{inspect(config_id)} with unexpected result: #{inspect(other)}")
7580
{:error, :unauthorized}
7681
end
7782
else
83+
Logger.warning("Client token verification failed for config_id=#{inspect(config_id)}: client_secret_token not configured")
7884
{:error, :unauthorized}
7985
end
8086
end

0 commit comments

Comments
 (0)