# SOLVED - Error Unauthorized on API requests

**URL:** <https://discourse.getcockpit.com/t/solved-error-unauthorized-on-api-requests/591>\
**Category:** Support\
**Created:** [February 19, 2019, 3:28pm UTC](https://discourse.getcockpit.com/t/solved-error-unauthorized-on-api-requests/591 "2019-02-19T15:28:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![malua](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/malua/32/248_2.png) [@malua](https://discourse.getcockpit.com/u/malua)\
**Post date:** [February 19, 2019, 3:28pm UTC](https://discourse.getcockpit.com/t/solved-error-unauthorized-on-api-requests/591/1 "2019-02-19T15:28:07Z")

</div>

I just set up cockpit with Apache.  
the web interface works as it should, but i cant access the apis. i always get

```
{
  "error":"Unauthorized"
}

```

i tried with the master key, with a custom token and with user tokens

does anybody have a clue? i thought that maybe it is apaches fault, but i have the .htaccess file with mod\_rewrite. also url navigation in the interface works, so rewrite should be correct

.htaccess:

```
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?$1
</IfModule>

```

apache config:

```
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin a@a
        DocumentRoot /var/www/domain.xyz/html
        ServerName domain.xyz

        <Directory /var/www/domain.xyz/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml $
        </IfModule>

       SSLCertificateFile /etc/letsencrypt/live/domain.xyz/fullchain.pem
       SSLCertificateKeyFile /etc/letsencrypt/live/domain.xyz/privkey.pem
       Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

```

any help is much appreciated!

---

<div class="post-metadata">

**Author:** ![malua](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/malua/32/248_2.png) [@malua](https://discourse.getcockpit.com/u/malua)\
**Post date:** [February 19, 2019, 3:43pm UTC](https://discourse.getcockpit.com/t/solved-error-unauthorized-on-api-requests/591/2 "2019-02-19T15:43:58Z")

</div>

Solved it by replacing my .htaccess with the one from [https://github.com/agentejo/cockpit/blob/next/.htaccess](https://github.com/agentejo/cockpit/blob/next/.htaccess)
