diegogarciadev / android_snipeitapp_config

Automatic configuration of Android SnipeIT APP
30 stars 13 forks source link

Unable to configure Server #1

Closed gilesytheking closed 3 years ago

gilesytheking commented 4 years ago

Hi,

I have created a new API key from Snipe-IT Admin (Manage API Keys -> Create New token)

I have copied my API key into the snipeitapp_config.php file. Then uploaded this into my snipe directory.

I have then entered the web address for my snipe install into the app. However when i click "Configure App" i get the following error - mydomain.com is not a valid snipe-it server

diegogarciadev commented 4 years ago

Hello, you have to put the file in public directory, you should be able to reach the config this way: http(s)://my-snipeit.server.com/snipeitapp_config.php

Please, give me your feedback.

Rergards.

ComSec0 commented 4 years ago

I am receiving the same error. Using Snipe-IT Version v4.9.4 - build 4437 (master). It appears to find the app config file just fine. I generated the API key on the console using the "php artisan passport:client --personal" commend.

diegogarciadev commented 4 years ago

Can you try to create api key in snipe-it web interface. I've never tested a command created key...

ComSec0 commented 4 years ago

Unfortunately I get an error message when trying to create an API key from the web interface. I will try and resolve that problem then generate a key from there.

On Aug 8, 2020, at 12:50 PM, diegogarciadev notifications@github.com wrote:

 Can you try to create api key in snipe-it web interface. I've never tested a command created key...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

gilesytheking commented 4 years ago

I have managed to configure the app by saving the snipeitapp_config.php in the public folder within my snipe install

https://install.snipeit.com/public/

The default folder permissions in the main directory wont allow access to the file. However the public folder is already setup for public access.

diegogarciadev commented 4 years ago

Your apache configuration should point to public folder as DocumentRoot so, /public/ is not necessary in URL path. https://install.snipeit.com/snipeitapp_config.php is the way you should connect.

ComSec0 commented 4 years ago

Ok, I was able to get an API key from the WEB UI. However, now I receive the not a valid server error message.

diegogarciadev commented 4 years ago

Can you reach https://install.snipeit.com/snipeitapp_config.php in your web browser? if not, app will not work

diegogarciadev commented 4 years ago

Any news about this issue? I'd like to help you to solve it.

ProxayFox commented 4 years ago

Hey There, Seem to be getting the same error in the App. Snipe-It is running within cPanel from the plugins (Not sure if that matters) "assets.example.com is not a valid snipe-it server" I can reach the API config with assets.example.com/snipeitapp_config.php, Also tried the manual entry into the app but get the same message Tested the API server with https://apitester.com/, seems to be sending a response. not too sure what might be happening. Hopefully this is helpful

diegogarciadev commented 4 years ago

@ProxayFox Hello, I've had an issue recently, the problem was with .htaccess you should have an http authentication directive:

`

Handle Authorization Header

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]`

Check it with: https://github.com/snipe/snipe-it/blob/master/public/.htaccess

ProxayFox commented 4 years ago

Are you saying to go from # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] Too # Handle Authorization Header # RewriteCond %{HTTP:Authorization} . # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

AwesomeWaffle commented 4 years ago

I am having this same issue and this is a fairly new install of SnipeIT. I've generating API keys from the web interface, as well as from the CLI. I can reach snipeitapp_config.php in a web browser. It looks like I have the http authentication directive in .htaccess, and it matches the one you linked. I'm not sure what to try next.

diegogarciadev commented 4 years ago

@AwesomeWaffle What's the error you see in the app?

diegogarciadev commented 4 years ago

@AwesomeWaffle Can you check #8 ?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

hmacugova commented 4 years ago

Hi, I have the same problem: Error 401 Unauthorized, but I cannot type my login user/password. I have Version v5.0.5-pre - build 5457 (master). I created key from WEB UI and with artisan also. I tried many API key write there, but without succes. It works for self-hosted Snipe IT or only for cloud? Thanks.

qwe765 commented 4 years ago

I had the same "Error 401 Unauthorized" problem. I solved it as follows:

  1. I loged as root.
  2. Clicked on the user and selected "Manage API Keys"
  3. Create a new token
  4. Copied / pasted the long key into the snipeitapp_config.php file
  5. "Configure app" in the mobile app.
hmacugova commented 4 years ago

I had the same "Error 401 Unauthorized" problem. I solved it as follows:

  1. I loged as root.
  2. Clicked on the user and selected "Manage API Keys"
  3. Create a new token
  4. Copied / pasted the long key into the snipeitapp_config.php file
  5. "Configure app" in the mobile app.

Hi, where do you login as root ? In the linux terminal? Or do you login as super admin on web UI and do you create new token? And which server address do you type? DNS name, or IP address, or this long API key. Is server address with snipeitapp_config.php at the end or it is without? Because I tried it the same and for me it does not work. Thank you

diegogarciadev commented 4 years ago

I had the same "Error 401 Unauthorized" problem. I solved it as follows:

  1. I loged as root.
  2. Clicked on the user and selected "Manage API Keys"
  3. Create a new token
  4. Copied / pasted the long key into the snipeitapp_config.php file
  5. "Configure app" in the mobile app.

Hi, where do you login as root ? In the linux terminal? Or do you login as super admin on web UI and do you create new token? And which server address do you type? DNS name, or IP address, or this long API key. Is server address with snipeitapp_config.php at the end or it is without? Because I tried it the same and for me it does not work. Thank you

hello, in the Android app you have to write your server address only. It doesn't matter if you write the ip or dns address. http(s)://dnsname.com or http(s)://192.168.0.0

Regards.

qwe765 commented 4 years ago

I had the same "Error 401 Unauthorized" problem. I solved it as follows:

  1. I loged as root.
  2. Clicked on the user and selected "Manage API Keys"
  3. Create a new token
  4. Copied / pasted the long key into the snipeitapp_config.php file
  5. "Configure app" in the mobile app.

Hi, where do you login as root ? In the linux terminal? Or do you login as super admin on web UI and do you create new token? And which server address do you type? DNS name, or IP address, or this long API key. Is server address with snipeitapp_config.php at the end or it is without? Because I tried it the same and for me it does not work. Thank you

Hi. I logged in as a super user to web UI and created a new token (I didn't have it). I typed a DNS fullname in mobile app like http://my-snipeit.domain.local. My snipeitapp_config.php file looks like

`<?php header('Content-Type: application/json');

define("API_KEY", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

$data['api_key'] = API_KEY;

echo json_encode($data);`

no commas at the beginning and at the end

hmacugova commented 3 years ago

I had the same "Error 401 Unauthorized" problem. I solved it as follows:

  1. I loged as root.
  2. Clicked on the user and selected "Manage API Keys"
  3. Create a new token
  4. Copied / pasted the long key into the snipeitapp_config.php file
  5. "Configure app" in the mobile app.

Hi, where do you login as root ? In the linux terminal? Or do you login as super admin on web UI and do you create new token? And which server address do you type? DNS name, or IP address, or this long API key. Is server address with snipeitapp_config.php at the end or it is without? Because I tried it the same and for me it does not work. Thank you

hello, in the Android app you have to write your server address only. It doesn't matter if you write the ip or dns address. http(s)://dnsname.com or http(s)://192.168.0.0

Regards.

Hi, it is not working for me. I have all configured like instructions. Now I have message Error - 1 : Hostname XXX.XXX.XXX.XXX not verified: certificate sha1/..........................................

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

hmacugova commented 3 years ago

Hi everyone, I need to say, it is still not working for me. I reinstall snipeit on new server. I created new API key, copied to snipeitapp_config.php. I have an access from my phone to snipeitapp_config.php - I open it in web browser. I also edit .htaccess file. Whatever I did, the result was Error 401: Unauthorized. Please, help!

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

diegogarciadev commented 3 years ago

Hi everyone, I need to say, it is still not working for me. I reinstall snipeit on new server. I created new API key, copied to snipeitapp_config.php. I have an access from my phone to snipeitapp_config.php - I open it in web browser. I also edit .htaccess file. Whatever I did, the result was Error 401: Unauthorized. Please, help!

Can you try this:

401 Unauthorized Error on API calls API tokens default to being valid for 40 years. If you run into this issue, you are most likely running a 32-bit version of PHP (which, why?). To work around this, in your .env, set API_TOKEN_EXPIRATION_YEARS to a smaller number, like 10 years.

tharple commented 1 year ago

I have not seen and answer to the question: How do I connect the app to my Snipe-IT managed cloud deployment? TIA

diegogarciadev commented 1 year ago

I have not seen and answer to the question:

How do I connect the app to my Snipe-IT managed cloud deployment?

TIA

I've never used managed version. Can you create api keys?

Alex9001 commented 7 months ago

Version v6.3.4 - build 13139 CPANEL INSTALL

PHP 8.0 and 8.1 same problem.

I have a valid SSL Cert from LetsEncrypt

I'm having same problem. I can reach https://snipe.server.com/snipeitapp_config.php in a browser. I did create an API key in web interface. And I input it into the snipeitapp_config.php

<?php
header('Content-Type: application/json');
define("API_KEY", "xXxAPI KEY THAT I GENERATEDxXx");
$data['api_key'] = API_KEY;
echo json_encode($data);

My .htaccess copied from https://github.com/snipe/snipe-it/blob/master/public/.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Needed for https://letsencrypt.org/ certificates.
    RewriteRule ^\.well-known/acme-challenge/ - [L]

    # Uncomment these two lines to force SSL redirect in Apache
    # RewriteCond %{HTTPS} off
    # RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Security Headers
    # Header set Strict-Transport-Security "max-age=2592000" env=HTTPS
    # Header set X-XSS-Protection "1; mode=block"
    # Header set X-Content-Type-Options nosniff
    # Header set X-Permitted-Cross-Domain-Policies "master-only"

</IfModule>
Options -Indexes

# DENY ACCESS TO IIS CONFIG FILE

# Apache 2.2+
<IfModule !authz_core_module>
    <Files "web.config">
        Order allow,deny
        Deny from all
    </Files>
</IfModule>

# Apache 2.4+
<IfModule authz_core_module>
    <Files "web.config">
      Require all denied
    </Files>
</IfModule>

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php81” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

Screenshot_20240422-041432