Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not want to work with API? #136

Open
KalixtShawxo opened this issue Oct 2, 2022 · 11 comments
Open

Does not want to work with API? #136

KalixtShawxo opened this issue Oct 2, 2022 · 11 comments

Comments

@KalixtShawxo
Copy link

I tried it with 2 different pi-holes, both of them scanned the QR code but when I try to access the statistics,I get :
"An error has occurred. Please check your Internet connection or whether the API has been set. "

Since the QR code scans in with all asterisks I can't verify it's putting the right code and I haven't yet tried to type it in manually yet.
Anything else I need to check?
The home page does work to show the current numbers.

Thanks.

@stolirocks1
Copy link

Same here. I have correct api key and statistics does not work. It never has.

@Tubeman-cell
Copy link

Same here. I have correct api key and statistics does not work. It never has. Perhaps you can write a work around?

@tien
Copy link
Owner

tien commented May 22, 2023

Hey guys, quite busy recently and haven't been able to spend much time going over this. I have just tested today with the latest pi.hole version and everything seems to be working fine for me?

@modem7
Copy link

modem7 commented May 31, 2023

Hey guys, quite busy recently and haven't been able to spend much time going over this. I have just tested today with the latest pi.hole version and everything seems to be working fine for me?

Heya,

I've come across the same issue myself.

My current Docker setup is as follows:

 #Pihole - Network wide adblocker, DNS cache and DHCP server
  pihole:
    image: pihole/pihole:latest
    container_name: Pihole
    hostname: PiHole-Master
    environment:
      # INTERFACE: $INTERFACE
      DNSMASQ_LISTENING: $DNSMASQ_LISTENING
      # ServerIP: $SERVER_IP
      PIHOLE_DNS_: $PIHOLE_DNS
      # VIRTUAL_HOST: $VIRTUAL_HOST
      WEB_BIND_ADDR: $SERVER_IP
      FTLCONF_LOCAL_IPV4: $SERVER_IP
      IPv6: false
      CORS_HOSTS: $CORS_HOSTS
      TZ: $TZ
      SKIPGRAVITYONBOOT: $SKIPGRAVITYONBOOT
      DNSSEC: $DNSSEC
      DNS_BOGUS_PRIV: $DNS_BOGUS_PRIV
      DNS_FQDN_REQUIRED: $DNS_FQDN_REQUIRED
      REV_SERVER: $REV_SERVER
      # DNSMASQ_USER: $DNSMASQ_USER
      PIHOLE_UID: $PUID
      PIHOLE_GID: $PGID
      WEB_UID: $PUID
      WEB_GID: $PGID
      REV_SERVER_TARGET: $REV_SERVER_TARGET
      REV_SERVER_CIDR: $REV_SERVER_CIDR
      REV_SERVER_DOMAIN: $REV_SERVER_DOMAIN
      CUSTOM_CACHE_SIZE: $CUSTOM_CACHE_SIZE
      WEBPASSWORD: $WEBPASSWORD
      WEBTHEME: default-dark
      FTLCONF_RATE_LIMIT: 0/0
      FTLCONF_MOZILLA_CANARY: $MOZILLA_CANARY
      FTLCONF_BLOCK_ICLOUD_PR: $BLOCK_ICLOUD_PR
    labels: 
      - "autoheal=true"
    cap_add:
      - CHOWN
      - SYS_NICE
      - NET_ADMIN
      - NET_BIND_SERVICE
      - NET_RAW
    network_mode: "host"
    dns:
      - "127.0.0.1"
      - "9.9.9.9"
    depends_on:
      - dnscrypt-proxy
    volumes:
      - $USERDIR/Pihole/etc/pihole:/etc/pihole/
      - $USERDIR/Pihole/etc/dnsmasq:/etc/dnsmasq.d/
      # run `touch $USERDIR/Pihole/etc/logs/pihole.log` first unless you like errors
      - $USERDIR/Pihole/etc/logs/pihole.log:/var/log/pihole.log
      - $PIBACKUPDIR:/backup
      - $PISCRIPTS/piholebackup.sh:/scripts/piholebackup.sh:ro
    restart: always
    mem_limit: 2048m
    mem_reservation: 256m

App version 10.0
Docker Tag 2023.05.2
Pi-hole v5.17.1
FTL v5.23
Web Interface v5.20.1

I have two Pihole instances running in their own dedicated VMs, and they have this issue.

I'm able to see:

  • Home
  • Statistics
  • Log

I have attempted to rescan the QR code as well as copy the API key manually.

If I go to <serverIP>/admin/api.php in a browser, I get the following:

{"domains_being_blocked":1766285,"dns_queries_today":29922,"ads_blocked_today":7253,"ads_percentage_today":24.239691,"unique_domains":2203,"queries_forwarded":12275,"queries_cached":10174,"clients_ever_seen":30,"unique_clients":30,"dns_queries_all_types":29922,"reply_UNKNOWN":406,"reply_NODATA":3754,"reply_NXDOMAIN":702,"reply_CNAME":6673,"reply_IP":15274,"reply_DOMAIN":2758,"reply_RRNAME":3,"reply_SERVFAIL":24,"reply_REFUSED":0,"reply_NOTIMP":0,"reply_OTHER":0,"reply_DNSSEC":0,"reply_NONE":0,"reply_BLOB":328,"dns_queries_all_replies":29922,"privacy_level":0,"status":"enabled","gravity_last_updated":{"file_exists":true,"absolute":1685240630,"relative":{"days":3,"hours":11,"minutes":18}}}

@bewA
Copy link

bewA commented Jul 16, 2023

I have what looks to be the same issue, I have 2 Pi-Holes running the same latest version and I get the same error. It only generates an error when trying to disable adblocking otherwise everything else works. Here is the error:

`t5.l: No transformation found: class io.ktor.utils.io.m -> class com.tien.piholeconnect.model.PiHoleStatusResponse
with response from http://xxx.xxx.xxx.xxx/admin/api.php?disable=300:
status: 200 OK
response headers:
cache-control: no-store, no-cache, must-revalidate
, content-length: 58
, content-security-policy: default-src 'self' 'unsafe-inline';
, content-type: text/html; charset=UTF-8
, date: Sun, 16 Jul 2023 07:43:57 GMT
, expires: Thu, 19 Nov 1981 08:52:00 GMT
, pragma: no-cache
, referrer-policy: same-origin
, server: lighttpd/1.4.59
, set-cookie: PHPSESSID=7i6hm1qf2no492n3prjrit79dq; path=/; HttpOnly; SameSite=Strict
, x-content-type-options: nosniff
, x-frame-options: DENY
, x-permitted-cross-domain-policies: none
, x-pi-hole: The Pi-hole Web interface is working!
, x-xss-protection: 0

at ia.c.a(SourceFile:227)
at com.tien.piholeconnect.repository.PiHoleRepositoryImpl$disable$2.invokeSuspend(SourceFile:129)
at rb.a.resumeWith(SourceFile:9)
at kotlinx.coroutines.k0.run(SourceFile:109)
at kotlinx.coroutines.internal.d.run(SourceFile:13)
at kotlinx.coroutines.scheduling.i.run(SourceFile:3)
at kotlinx.coroutines.scheduling.a.run(SourceFile:77)

`

I don't have an admin password set however are you sending the API key in the URL e.g.

Adding &auth=apitoken to the endpoint URL?

@tien
Copy link
Owner

tien commented Jul 16, 2023

@bewA yeh it does seems like your request is missing the API token. From this logic here, if you have added the API token, then it should be included in the request.

@tien
Copy link
Owner

tien commented Jul 16, 2023

@modem7 latest version will shows the actual error message. Can you see what it is?

@bewA
Copy link

bewA commented Jul 16, 2023

@bewA yeh it does seems like your request is missing the API token. From this logic here, if you have added the API token, then it should be included in the request.

I don't have an API token set in the app and I can't set one in pihole because I don't have a password set.

Which I've just realised! 😂 Can this work without an API token being set?

@tien
Copy link
Owner

tien commented Jul 16, 2023

@bewA I haven't tested against cases where there isn't any token yet, will have that done next. In the meantime, can you check what happen if you just set the API token to some random value?

@modem7
Copy link

modem7 commented Jul 16, 2023

@modem7 latest version will shows the actual error message. Can you see what it is?

xa.f: Illegal input: Unexpected JSON token at offset 65526: Expected end of the object '}', but had '4' instead at path: $.data[421]
JSON input: .....:1645401348,"date_modified":1645
	at ya.j.a(SourceFile:345)
	at xa.b.emit(SourceFile:89)
	at kotlinx.coroutines.flow.h.collect(SourceFile:97)
	at xa.c.collect(SourceFile:27)
	at h6.pc.j(SourceFile:73)
	at h6.pb.f(SourceFile:90)
	at pa.f.b(SourceFile:246)
	at ha.a.invokeSuspend(SourceFile:292)
	at ha.a.invoke(SourceFile:50)
	at db.k.f(SourceFile:36)
	at db.k.d(SourceFile:30)
	at ha.b.invokeSuspend(SourceFile:179)
	at ha.b.invoke(SourceFile:36)
	at db.k.f(SourceFile:36)
	at db.k.d(SourceFile:30)
	at db.k.e(SourceFile:8)
	at na.n.invokeSuspend(SourceFile:64)
	at na.n.invoke(SourceFile:27)
	at db.k.f(SourceFile:36)
	at db.k.d(SourceFile:30)
	at db.k.a(SourceFile:24)
	at db.d.a(SourceFile:196)
	at ia.c.a(SourceFile:170)
	at com.tien.piholeconnect.repository.PiHoleRepositoryImpl$getFilterRules$2.invokeSuspend(SourceFile:129)
	at rb.a.resumeWith(SourceFile:9)
	at kotlinx.coroutines.k0.run(SourceFile:109)
	at kotlinx.coroutines.internal.d.run(SourceFile:13)
	at kotlinx.coroutines.scheduling.i.run(SourceFile:3)
	at kotlinx.coroutines.scheduling.a.run(SourceFile:77)
Caused by: ve.p: Unexpected JSON token at offset 65526: Expected end of the object '}', but had '4' instead at path: $.data[421]
JSON input: .....:1645401348,"date_modified":1645
	at i6.v6.e(SourceFile:33)
	at i6.v6.d(SourceFile:35)
	at ve.a.s(SourceFile:64)
	at ve.a.t(Unknown Source:12)
	at ve.a.u(SourceFile:114)
	at ve.a.E(SourceFile:42)
	at ve.f0.j(SourceFile:51)
	at ve.c0.c(SourceFile:35)
	at com.tien.piholeconnect.model.PiHoleFilterRule$$serializer.deserialize(SourceFile:1)
	at com.tien.piholeconnect.model.PiHoleFilterRule$$serializer.deserialize(SourceFile:2)
	at ve.c0.r(SourceFile:67)
	at h6.sd.v(SourceFile:11)
	at ve.c0.v(SourceFile:49)
	at te.t.f(SourceFile:8)
	at te.a.e(SourceFile:38)
	at te.a.deserialize(SourceFile:6)
	at ve.c0.r(SourceFile:67)
	at h6.sd.v(SourceFile:11)
	at ve.c0.v(SourceFile:49)
	at com.tien.piholeconnect.model.PiHoleFilterRules$$serializer.deserialize(SourceFile:1)
	at com.tien.piholeconnect.model.PiHoleFilterRules$$serializer.deserialize(SourceFile:2)
	at ve.c0.r(SourceFile:67)
	at ya.j.a(SourceFile:221)
	... 28 more

@bewA
Copy link

bewA commented Jul 16, 2023

Ok just shoved in random characters for the API token in the app.

t5.l: No transformation found: class io.ktor.utils.io.m -> class com.tien.piholeconnect.model.PiHoleStatusResponse
with response from http://xxx.xxx.xxx.xxx/admin/api.php?auth=**************************************************&disable=10:
status: 200 OK
response headers:
cache-control: no-store, no-cache, must-revalidate
, content-length: 15
, content-security-policy: default-src 'self' 'unsafe-inline';
, content-type: text/html; charset=UTF-8
, date: Sun, 16 Jul 2023 13:38:12 GMT
, expires: Thu, 19 Nov 1981 08:52:00 GMT
, pragma: no-cache
, referrer-policy: same-origin
, server: lighttpd/1.4.59
, set-cookie: PHPSESSID=p7ivbr3dhfjojiepaqopus3os3; path=/; HttpOnly; SameSite=Strict
, x-content-type-options: nosniff
, x-frame-options: DENY
, x-permitted-cross-domain-policies: none
, x-pi-hole: The Pi-hole Web interface is working!
, x-xss-protection: 0

at ia.c.a(SourceFile:227)
at com.tien.piholeconnect.repository.PiHoleRepositoryImpl$disable$2.invokeSuspend(SourceFile:129)
at rb.a.resumeWith(SourceFile:9)
at kotlinx.coroutines.k0.run(SourceFile:109)
at kotlinx.coroutines.internal.d.run(SourceFile:13)
at kotlinx.coroutines.scheduling.i.run(SourceFile:3)
at kotlinx.coroutines.scheduling.a.run(SourceFile:77)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants