PDF document generation PAT not valid error

0
Hi ,We have used PDF document generator in our application.When user clicks a form form downloads in pdf format.Recenlty i saw in acceptance environment it stopped working saying Access token is not valid.I created a personal access token in Mendix cloud -user profile->developer settings and trying to register in the app.But when Iam trying to register with App id,App url and PAT ,its saying "Failed to register application: Invalid personal access token (PAT)"I checked each and everything when copy pasting tokens and app id ,there is no issue in that.Even access token is created with Deployemt read access just like production.In production it works but not in acceptance.Please help if any one faced the same issuethanks
asked
2 answers
0

Hi Vijay,

Since Production is working but Acceptance is failing with "Invalid personal access token (PAT)", I would first verify that you're registering the PDF Document Generation service against the Acceptance application details, not the Production ones.

A few things I've seen cause this:

  • Using the Acceptance App ID with a PAT created under a different Mendix account.
  • Accidentally using the Production App URL/App ID while registering Acceptance.
  • PAT created successfully, but not copied completely (extra spaces/new lines can cause validation failures).
  • The user who generated the PAT no longer has the required access to the Acceptance application.

One important point: PATs are user-specific, not environment-specific. If the same PAT works for one application but fails for another, I would check application permissions and the registration details rather than the token itself.

Since the error occurs during registration itself:

Failed to register application:
Invalid personal access token (PAT)

I would try the following:

  1. Generate a completely new PAT.
  2. Give it all recommended permissions temporarily for testing.
  3. Copy the token directly into a text editor first to ensure no hidden characters.
  4. Verify the Acceptance App ID and URL from the Developer Portal.
  5. Confirm the Mendix account that generated the PAT has access to the Acceptance app/team.

Also compare the PDF Document Generation configuration between Production and Acceptance. If Production was registered previously and Acceptance was re-created, cloned, or moved between teams, I've seen registration issues caused by mismatched App IDs.

The fact that PDF generation was working before and suddenly stopped also makes me check whether:

  • The PAT expired or was revoked.
  • The user who created the PAT left the team or lost permissions.
  • The Acceptance application was recreated or migrated.

My suspicion is that this is an application access/App ID mismatch issue rather than a problem with the PDF Document Generator itself, especially since Production continues to work normally.

Hope this helps.


answered
0

Hi Vijay,


Since PDF generation works in Production but the Acceptance environment suddenly reports “Access token is not valid”, I would focus on the DocGen app registration for the Acceptance environment, rather than the PDF template itself.


One important point: the current PDF Document Generation documentation does not describe creating a normal Mendix Cloud PAT with mx:deployment:read and using that as the DocGen registration credential. The Document Generation module manages its own access token after the app environment is registered.


I would check the following:

  1. Re-register the Acceptance environment
  2. Each environment must be registered separately. The registration is tied to the exact application URL. If the Acceptance URL changed, or a database backup was restored from another environment, the registration needs to be done again.
  3. Check the URL carefully
  4. Make sure the URL entered during registration is exactly the current Acceptance URL, including HTTPS and without an incorrect trailing path.
  5. The troubleshooting documentation specifically calls out:
“Domain verification failed, invalid token”
  1. when the service cannot verify that the application is the one being registered.
  2. Check the Document Generation scheduled event
  3. Make sure:
DocumentGeneration
 └─ Scheduled events
      └─ SE_AccessToken_Refresh

is enabled.

This scheduled event is responsible for automatically refreshing the token used to secure communication with the Document Generation service.

  1. Don't use the Deployment PAT for this
  2. A PAT with mx:deployment:read is intended for Mendix deployment APIs, not as a replacement for the Document Generation service's application registration token.
  3. Check /docgen/ access
  4. If Acceptance has path-based/IP restrictions, make sure /docgen/ is accessible to the Document Generation service. Mendix specifically requires the /docgen/ path to be accessible when using the service.

So, because Production is working with the same application, my first step would be:

Acceptance → open the Snip_AppRegistration page → register/renew that specific environment again using its current Acceptance URL.


If registration itself fails, the exact error is important. For example, “Invalid Developer Credentials”, “Invalid App”, and “Domain verification failed” point to different problems. Mendix has a dedicated troubleshooting table for these cases.


I would not generate another random PAT or change the PDF template first. This looks much more like an Acceptance environment registration/token issue.


Hope this helps.

answered