Issue with Viewing Invoice PDFs in Square Without Authentication

I am implementing a “View Invoice PDF” feature on my webpage, allowing users to access their invoice PDFs via the following Square Sandbox URL:

https://app.squareupsandbox.com/invoices/{invoiceId}/attachments/pdf?inline=true

Currently, this functionality works if I am logged into the Square Dashboard on the same browser. However, when accessed from a different browser or by an unauthenticated user, the following authentication error occurs:

{ “errors”: [ { “category”: “AUTHENTICATION_ERROR”, “code”: “UNAUTHORIZED”, “detail”: “This request could not be authorized.” } ] }

This prevents users from viewing and downloading their invoice PDFs unless they are logged into Square. Is there a way to resolve this issue, or is authentication a strict requirement for accessing invoice attachments?

Best regards,

:waving_hand: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Troubleshoot In-App Payments SDK Problems
Invoices API
https://developer.squareup.com/docs/oauth-api/walkthrough2

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

I believe this is because it’s a sandbox invoice and you have to have the Dashboard open to see the invoice. In production the invoices will be accessible. :slight_smile: