"Requires an 'view' access for the website id = 1"

Hello,

I’m new to Piwik (love it!) and programming in general. I have a Piwik widget embedded in a private page. In Google Chrome, when I log in to the private page (via the CMS’s login system, not Piwik), I can view the widget. Then I log out and I try the process again in Safari, except the page gives me this error instead of showing the widget:

“You can’t access this resource as it requires an ‘view’ access for the website id = 1”

The widget is the Visits Overview w/ Graph. I’ve created a User for this Website and added that User’s token_auth to the end of the embedded URL. Perhaps I am supposed to adjust the token_auth a certain way when adding it to the end of the URL? In the end of the URL, I add it immediately next to where it says “widget=1,” for greater clarity, alongside the “1”…

I’m sure there is something simple on my end that I am forgetting. Does anyone have any suggestions?

Much appreciated,
sd

1 Like

What is the full widget code you are using (remove your domain and change the token_auth before posting)

Thank you for your interest Matt. I solved the problem. I was not adding " &token_auth= " before the actual token_auth number. Maybe I missed that step in the documentation or it is just presumed understood by all web developers… I’m new to programming in general so I didn’t know.

Thanks again. Take care.

SD

Thanks for the feedback, I updated page at: Embedding Piwik Reports in Other Websites or Apps - Analytics Platform - Matomo

"Then, copy the ‘token_auth’ of this user from the Manage Users page, and paste it at the end of the widget URL in the Widget embed HTML code: &token_auth=your_token_auth_here "

hopefully it is easier to understand?

I’m using the Python Reporting API Client which is available here.

from piwikapi.analytics import PiwikAnalytics

pa = PiwikAnalytics()
pa.set_api_url('http://10.***.***.***:10443/piwik/index.php?')
pa.set_id_site(3)
pa.set_method('ImageGraph.get')
pa.set_parameter('apiModule', 'UserCountry')
pa.set_parameter('apiAction', 'getCountry')
image = pa.send_request()

When I try to execute the above code I get the following error
Error: You can\'t access this resource as it requires an \'view\' access for the website id = 3.

I found the above code somewhere in the above library’s reference document.

Hello,

I am the same problem of Nagesh.

I have the URL of the domain and the token, but it is not working.

I am using this code :

api_url="https://XXXX.com/"
params = {
    'method': 'UserCountry.getCountry',
    'idSite': '1',
    'period':'day',
    'date':'yesterday',
    'format': 'json',
    'module': 'API',
    'token_auth': "XXXXXX",
}
r = requests.post(api_url, params)
r = requests.get(api_url, params)
r.json()

And I have this error :

"You can't access this resource as it requires 'view' access for the website id = 1."

Thanks for your help !

Hey @Paul_Martin ,

Were you able to solve this issue?

Thanks,
Anudeep.

it should work as GET
https://demo.matomo.cloud/?module=API&method=UserCountry.getCountry&idSite=1&period=day&date=yesterday&format=JSON&token_auth=anonymous works fine.

Hi @heurteph-ei ,

The request results in empty array when I use my site URL and token. I have been given read access.

Do I need to request any kind of particular access from my admin?

Thanks,
Anudeep.

1 Like

Hi @amarupak
Sorry I missed your last message…
Did you finally solve your problem?