Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- `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.
- 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.

## [2026-02-27]

Expand Down
14 changes: 10 additions & 4 deletions lib/peek_app_sdk/token.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule PeekAppSDK.Token do
use Joken.Config
require Logger

alias PeekAppSDK.AccountUser
alias PeekAppSDK.Config
Expand Down Expand Up @@ -31,10 +32,12 @@ defmodule PeekAppSDK.Token do
{:ok, %{"sub" => sub} = claims} ->
{:ok, sub, claims}

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

_ ->
other ->
Logger.warning("Token verification failed for config_id=#{inspect(config_id)} with unexpected result: #{inspect(other)}")
{:error, :unauthorized}
end
end
Expand Down Expand Up @@ -68,13 +71,16 @@ defmodule PeekAppSDK.Token do
{:ok, %{"sub" => sub} = claims} ->
{:ok, sub, claims}

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

_ ->
other ->
Logger.warning("Client token verification failed for config_id=#{inspect(config_id)} with unexpected result: #{inspect(other)}")
{:error, :unauthorized}
end
else
Logger.warning("Client token verification failed for config_id=#{inspect(config_id)}: client_secret_token not configured")
{:error, :unauthorized}
end
end
Expand Down