Issue with Piwik PRO API Authentication – 401 Unauthorized

Hi everyone,

I’m trying to integrate Piwik PRO’s API into my web application, but I’m running into an authentication issue. I’m using the OAuth 2.0 client credentials flow to obtain an access token, but when I try to make a request to the API, I keep getting a 401 Unauthorized error.

Here’s what I’ve done so far:

  1. Token Request:
  • I’m sending a POST request to https://{your-domain}/auth/token with my client ID and client secret.
  • The response returns an access token successfully.
  1. API Request:
  • I’m making a GET request to https://{your-domain}/api/analytics/v1/reports
  • I include the token in the Authorization header like this:

Authorization: Bearer {access_token}

However, the API returns:

{
  "error": "unauthorized",
  "message": "Invalid or expired access token"
}

Debugging Attempts:

  • I verified that the token is valid and not expired.
  • Tried regenerating the token multiple times.
  • Tested the API request in Postman and via curl, but still get the same error.
  • Confirmed that my client has the required API scopes and permissions.

Am I missing something? Does Piwik PRO require additional headers or authentication steps for API access? Any guidance would be greatly appreciated!

Thanks in advance.

I am seeking guidance thanks.

Hi!
Could you elaborate on what you’re trying to get from this request?

If you’re trying to execute a query, you should try sending a POST request to this endpoint:
https://{account}.piwik.pro/api/analytics/v1/query/

Here is our documentation on that: