Skip to content

Bug: Instagram Standalone integration fails in self‑hosted Postiz ("Invalid API key") #1122

@edunavajas

Description

@edunavajas

📜 Description

instagram Standalone Login cannot be completed on a self‑hosted Postiz installation. The OAuth flow with Instagram completes successfully (code is issued, token exchange works), but Postiz fails at the final step with a 409 Conflict and response:

{"msg":"Invalid API key"}

This appears to be an internal Postiz error (not returned by Instagram) and happens consistently across versions.

Environment

Postiz: v2.10.1 (also tested 2.9.x)
Deployment: Self‑hosted via Coolify (Docker Compose)
Reverse proxy: Cloudflare (also tested with proxy disabled)
Domain: HTTPS, valid cert
Cloudflare R2: Configured and working

Configuration (only relevant env vars)

SERVICE_FQDN_POSTIZ=https://
SERVICE_FQDN_POSTIZ_5000=https://:5000
SERVICE_PASSWORD_JWTSECRET=
SERVICE_URL_POSTIZ=https://.com
SERVICE_URL_POSTIZ_5000=https://:5000
BACKEND_INTERNAL_URL=http://localhost:3000
INSTAGRAM_APP_ID=
INSTAGRAM_APP_SECRET=
NOT_SECURED=false
NEXT_PUBLIC_BACKEND_URL=${SERVICE_URL_POSTIZ}/api
MAIN_URL=${SERVICE_URL_POSTIZ}
FRONTEND_URL=${SERVICE_URL_POSTIZ}

No Facebook Business Login is used. Only Instagram Standalone.

👟 Reproduction steps

  1. Go to Integrations → Instagram (Standalone)
  2. Click connect
  3. Login to Instagram
  4. Accept permissions
  5. Instagram redirects back to:/integrations/social/instagram-standalone?code=...&state=...
  6. Frontend triggers: POST /api/integrations/social/instagram-standalone/connect
  7. Backend responds with 409 and: {"msg":"Invalid API key"}

Integration is not created and UI cannot proceed.

👍 Expected behavior

After completing the Instagram Standalone OAuth flow:

User logs in to Instagram and approves requested permissions

Instagram redirects back to Postiz with a valid code and state

Postiz successfully exchanges the code for an Instagram access_token

The Instagram account is persisted as an integration in Postiz

The integration appears in the UI under Integrations / Channels

The user can proceed to publish content without further errors

👎 Actual Behavior with Screenshots

User completes Instagram login and approves permissions

Instagram redirects back to Postiz correctly

Frontend sends:

POST /api/integrations/social/instagram-standalone/connect

Backend responds with HTTP 409 and:

{"msg":"Invalid API key"}

Integration is not created and does not appear in the UI

User cannot proceed past the integration step

Image Image Image Image Image Image Image

💻 Operating system

Linux

🤖 Node Version

v22.21.1

📃 Provide any additional context for the Bug.

What works / what is confirmed

Instagram OAuth code is valid

Manual token exchange works using:

POST https://api.instagram.com/oauth/access_token

Instagram returns access_token, user_id and correct permissions

Redirect URI matches exactly

Same result with Cloudflare proxy ON/OFF

Same result across Postiz versions

This confirms Instagram is correctly configured and the failure happens after OAuth, inside Postiz.

observations

The error message does not come from Instagram

Backend logs show no error output for this request (error seems swallowed)

When calling the endpoint manually later (Postman), it can return 500 instead of 409

Backend responds with x-powered-by: Express, request does reach Nest backend

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions