mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-09 22:52:58 +03:00
🐛 Bug Report: Cloudflare Zero Trust OIDC ERROR: Failed to exchange code for token. #362
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @EvasiveXkiller on GitHub.
Reproduction steps
I followed the example in the documentation to setup Pocket ID with Cloudflare ZT.
Expected behavior
Authentication works.
Actual Behavior
I got the following error.
OIDC ERROR: Failed to exchange code for token. Make sure the client secret is correct.
undefined.
Version and Environment
Pocket ID: v0.32
Reverse Proxy: HAProxy version 3.1.3-1~bpo12+1 2025/01/29
My reverse proxy is running on a non default port, ie. https://oidc.tld.com:49172
Log Output
@EvasiveXkiller commented on GitHub:
I copied the token URL from the dashboard, and modified it to include to port since it does not have it.
The original one is https://oidc.tld.com/api/oidc/token, while mine is modified to https://oidc.tld.com:49172/api/oidc/token
I did run some basic tests on reachability using
curland everything seems to return with no issues.@kmendell Would you mind giving a general direction on how the Cloudflare tunnel is supposed to be used? I have a tunnel running on that machine as well so might be able to leverage that
@kmendell commented on GitHub:
Cloudflare tunnel is in itself a reverse proxy of sorts , so you should jut proxy directly to the pocket id service vs proxying to another reverse proxy that just causes problems.
For example:
cloudflare tunnel config would be
id.example.com
and
http://pocketidip:3000
@kmendell commented on GitHub:
Yes @stonith404 is correct, you need to make sure both pocket id and cloudflare can reach each other in both directions for it to work. if you use Cloudflare tunnel that's a simple way to do this.
@EvasiveXkiller commented on GitHub:
Alright great! Thank you for the direction. Ditched my reverse proxy and opted for the cloudflare one instead, works perfectly now.
Closing this issue.
@stonith404 commented on GitHub:
What did you enter for "Token URL"? Based on the logs Cloudflare isn't able to call this endpoint. You've either entered a wrong "Token URL" or it's not reachable by the Cloudflare servers.